documented xma.h, though terse

This commit is contained in:
hyung-hwan 2010-08-05 01:25:48 +00:00
parent e5e0bc9a78
commit 65698c30a2
11 changed files with 157 additions and 572 deletions

View File

@ -790,7 +790,7 @@ HTML_FOOTER =
# the style sheet file to the HTML output directory, so don't put your own # the style sheet file to the HTML output directory, so don't put your own
# stylesheet in the HTML output directory as well, or it will be erased! # stylesheet in the HTML output directory as well, or it will be erased!
HTML_STYLESHEET = ./doxygen.css HTML_STYLESHEET =
# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
# files or namespaces will be aligned in HTML using tables. If set to # files or namespaces will be aligned in HTML using tables. If set to

View File

@ -1,502 +0,0 @@
/* The standard CSS for doxygen */
body, table, div, p, dl {
/* font-family: Lucida Grande, Verdana, Geneva, Arial, sans-serif;
font-size: 90%; */
font-family: sans-serif;
}
/* @group Heading Levels */
h1 {
text-align: center;
font-size: 150%;
}
h2 {
font-size: 120%;
}
h3 {
font-size: 100%;
}
dt {
font-weight: bold;
}
div.multicol {
-moz-column-gap: 1em;
-webkit-column-gap: 1em;
-moz-column-count: 3;
-webkit-column-count: 3;
}
p.startli, p.startdd {
margin-top: 2px;
}
p.endli {
margin-bottom: 0px;
}
p.enddd {
margin-bottom: 4px;
}
/* @end */
caption {
font-weight: bold;
}
span.legend {
font-size: 70%;
text-align: center;
}
div.qindex, div.navtab{
background-color: #e8eef2;
border: 1px solid #84b0c7;
text-align: center;
margin: 2px;
padding: 2px;
}
div.qindex, div.navpath {
width: 100%;
line-height: 140%;
}
div.navtab {
margin-right: 15px;
}
/* @group Link Styling */
a {
color: #153788;
font-weight: normal;
text-decoration: none;
}
.contents a:visited {
color: #1b77c5;
}
a:hover {
text-decoration: underline;
}
a.qindex {
font-weight: bold;
}
a.qindexHL {
font-weight: bold;
background-color: #6666cc;
color: #ffffff;
border: 1px double #9295C2;
}
.contents a.qindexHL:visited {
color: #ffffff;
}
a.el {
font-weight: bold;
}
a.elRef {
}
a.code {
}
a.codeRef {
}
/* @end */
dl.el {
margin-left: -1cm;
}
.fragment {
font-family: monospace, fixed;
/*font-size: 105%;*/
font-size: 95%;
}
pre.fragment {
/*border: 1px solid #CCCCCC;*/
border: 1px dashed #CCCCCC;
/*background-color: #f5f5f5;*/
background-color: #F0FFF0;
padding: 4px 6px;
margin: 4px 8px 4px 2px;
}
div.ah {
background-color: black;
font-weight: bold;
color: #ffffff;
margin-bottom: 3px;
margin-top: 3px
}
div.groupHeader {
margin-left: 16px;
margin-top: 12px;
margin-bottom: 6px;
font-weight: bold;
}
div.groupText {
margin-left: 16px;
font-style: italic;
}
body {
background: white;
color: black;
margin-right: 20px;
margin-left: 20px;
}
td.indexkey {
background-color: #e8eef2;
font-weight: bold;
border: 1px solid #CCCCCC;
margin: 2px 0px 2px 0;
padding: 2px 10px;
}
td.indexvalue {
background-color: #e8eef2;
border: 1px solid #CCCCCC;
padding: 2px 10px;
margin: 2px 0px;
}
tr.memlist {
background-color: #f0f0f0;
}
p.formulaDsp {
text-align: center;
}
img.formulaDsp {
}
img.formulaInl {
vertical-align: middle;
}
div.center {
text-align: center;
margin-top: 0px;
margin-bottom: 0px;
padding: 0px;
}
div.center img {
border: 0px;
}
img.footer {
border: 0px;
vertical-align: middle;
}
/* @group Code Colorization */
span.keyword {
color: #008000
}
span.keywordtype {
color: #604020
}
span.keywordflow {
color: #e08000
}
span.comment {
color: #800000
}
span.preprocessor {
color: #806020
}
span.stringliteral {
color: #002080
}
span.charliteral {
color: #008080
}
span.vhdldigit {
color: #ff00ff
}
span.vhdlchar {
color: #000000
}
span.vhdlkeyword {
color: #700070
}
span.vhdllogic {
color: #ff0000
}
/* @end */
.search {
color: #003399;
font-weight: bold;
}
form.search {
margin-bottom: 0px;
margin-top: 0px;
}
input.search {
font-size: 75%;
color: #000080;
font-weight: normal;
background-color: #e8eef2;
}
td.tiny {
font-size: 75%;
}
.dirtab {
padding: 4px;
border-collapse: collapse;
border: 1px solid #84b0c7;
}
th.dirtab {
background: #e8eef2;
font-weight: bold;
}
hr {
height: 0;
border: none;
border-top: 1px solid #666;
}
/* @group Member Descriptions */
.mdescLeft, .mdescRight,
.memItemLeft, .memItemRight,
.memTemplItemLeft, .memTemplItemRight, .memTemplParams {
background-color: #FAFAFA;
border: none;
margin: 4px;
padding: 1px 0 0 8px;
}
.mdescLeft, .mdescRight {
padding: 0px 8px 4px 8px;
color: #555;
}
.memItemLeft, .memItemRight, .memTemplParams {
border-top: 1px solid #ccc;
}
.memItemLeft, .memTemplItemLeft {
white-space: nowrap;
}
.memTemplParams {
color: #606060;
white-space: nowrap;
}
/* @end */
/* @group Member Details */
/* Styles for detailed member documentation */
.memtemplate {
font-size: 80%;
color: #606060;
font-weight: normal;
margin-left: 3px;
}
.memnav {
background-color: #e8eef2;
border: 1px solid #84b0c7;
text-align: center;
margin: 2px;
margin-right: 15px;
padding: 2px;
}
.memitem {
padding: 0;
margin-bottom: 10px;
}
.memname {
white-space: nowrap;
font-weight: bold;
}
.memproto, .memdoc {
border: 1px solid #84b0c7;
}
.memproto {
padding: 0;
background-color: #d5e1e8;
font-weight: bold;
-webkit-border-top-left-radius: 8px;
-webkit-border-top-right-radius: 8px;
-webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15);
-moz-border-radius-topleft: 8px;
-moz-border-radius-topright: 8px;
-moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px;
}
.memdoc {
padding: 2px 5px;
background-color: #eef3f5;
border-top-width: 0;
-webkit-border-bottom-left-radius: 8px;
-webkit-border-bottom-right-radius: 8px;
-webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15);
-moz-border-radius-bottomleft: 8px;
-moz-border-radius-bottomright: 8px;
-moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px;
}
.paramkey {
text-align: right;
}
.paramtype {
white-space: nowrap;
}
.paramname {
color: #602020;
white-space: nowrap;
}
.paramname em {
font-style: normal;
}
/* @end */
/* @group Directory (tree) */
/* for the tree view */
.ftvtree {
font-family: sans-serif;
margin: 0.5em;
}
/* these are for tree view when used as main index */
.directory {
font-size: 9pt;
font-weight: bold;
}
.directory h3 {
margin: 0px;
margin-top: 1em;
font-size: 11pt;
}
/*
The following two styles can be used to replace the root node title
with an image of your choice. Simply uncomment the next two styles,
specify the name of your image and be sure to set 'height' to the
proper pixel height of your image.
*/
/*
.directory h3.swap {
height: 61px;
background-repeat: no-repeat;
background-image: url("yourimage.gif");
}
.directory h3.swap span {
display: none;
}
*/
.directory > h3 {
margin-top: 0;
}
.directory p {
margin: 0px;
white-space: nowrap;
}
.directory div {
display: none;
margin: 0px;
}
.directory img {
vertical-align: -30%;
}
/* these are for tree view when not used as main index */
.directory-alt {
font-size: 100%;
font-weight: bold;
}
.directory-alt h3 {
margin: 0px;
margin-top: 1em;
font-size: 11pt;
}
.directory-alt > h3 {
margin-top: 0;
}
.directory-alt p {
margin: 0px;
white-space: nowrap;
}
.directory-alt div {
display: none;
margin: 0px;
}
.directory-alt img {
vertical-align: -30%;
}
/* @end */
address {
font-style: normal;
color: #333;
}

View File

@ -1,5 +1,9 @@
/** @page cmn COMMON FUNCTIONS /** @page cmn COMMON FUNCTIONS
@section xma MEMORY ALLOCATOR
QSE provides a memory allocator #qse_xma_t for private heap management.
@section rex REGULAR EXPRESSION @section rex REGULAR EXPRESSION
QSE provides regular expression handling functions. QSE provides a regular expression processor #qse_rex_t.
*/ */

View File

@ -19,7 +19,7 @@ As the library grows, more utilities will be added.
The library is licensed under the GNU Lesser General Public License version 3: The library is licensed under the GNU Lesser General Public License version 3:
http://www.gnu.org/licenses/ http://www.gnu.org/licenses/
The project webpage: http://qse.googlecode.com/ The project webpage: http://code.abiyo.net/@qse
For further information, contact: For further information, contact:
Chung, Hyung-Hwan <hyunghwan.chung@gmail.com> Chung, Hyung-Hwan <hyunghwan.chung@gmail.com>

View File

@ -1,5 +1,5 @@
/* /*
* $Id: htb.h 333 2010-07-13 13:29:02Z hyunghwan.chung $ * $Id: htb.h 341 2010-08-04 07:25:48Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE. This file is part of QSE.
@ -308,6 +308,9 @@ void qse_htb_setcopier (
qse_htb_copier_t copier /**< element copier */ qse_htb_copier_t copier /**< element copier */
); );
/**
* The qse_htb_getfreeer() function returns a custom element destroyer.
*/
qse_htb_freeer_t qse_htb_getfreeer ( qse_htb_freeer_t qse_htb_getfreeer (
qse_htb_t* htb, /**< hash table */ qse_htb_t* htb, /**< hash table */
qse_htb_id_t id /**< QSE_HTB_KEY or QSE_HTB_VAL */ qse_htb_id_t id /**< QSE_HTB_KEY or QSE_HTB_VAL */

View File

@ -1,5 +1,5 @@
/* /*
* $Id: lda.h 327 2010-05-10 13:15:55Z hyunghwan.chung $ * $Id: lda.h 341 2010-08-04 07:25:48Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE. This file is part of QSE.
@ -72,18 +72,18 @@ typedef enum qse_lda_walk_t qse_lda_walk_t;
* memory allocated for copy. * memory allocated for copy.
*/ */
typedef void* (*qse_lda_copier_t) ( typedef void* (*qse_lda_copier_t) (
qse_lda_t* lda /* lda */, qse_lda_t* lda /**< array */,
void* dptr /* the pointer to data to copy */, void* dptr /**< pointer to data to copy */,
qse_size_t dlen /* the length of data to copy */ qse_size_t dlen /**< length of data to copy */
); );
/** /**
* The qse_lda_freeer_t type defines a node destruction callback. * The qse_lda_freeer_t type defines a node destruction callback.
*/ */
typedef void (*qse_lda_freeer_t) ( typedef void (*qse_lda_freeer_t) (
qse_lda_t* lda /* lda */, qse_lda_t* lda /**< array */,
void* dptr /* the pointer to data to free */, void* dptr /**< pointer to data to free */,
qse_size_t dlen /* the length of data to free */ qse_size_t dlen /**< length of data to free */
); );
/** /**
@ -96,11 +96,11 @@ typedef void (*qse_lda_freeer_t) (
* *
*/ */
typedef int (*qse_lda_comper_t) ( typedef int (*qse_lda_comper_t) (
qse_lda_t* lda /* a linear dynamic array */, qse_lda_t* lda /* array */,
const void* dptr1 /* a data pointer */, const void* dptr1 /* data pointer */,
qse_size_t dlen1 /* a data length */, qse_size_t dlen1 /* data length */,
const void* dptr2 /* a data pointer */, const void* dptr2 /* data pointer */,
qse_size_t dlen2 /* a data length */ qse_size_t dlen2 /* data length */
); );
/** /**
@ -110,9 +110,9 @@ typedef int (*qse_lda_comper_t) (
* pointers and their lengths are equal. * pointers and their lengths are equal.
*/ */
typedef void (*qse_lda_keeper_t) ( typedef void (*qse_lda_keeper_t) (
qse_lda_t* lda /* lda */, qse_lda_t* lda /**< array */,
void* vptr /* the pointer to a value */, void* vptr /**< pointer to a value */,
qse_size_t vlen /* the length of a value */ qse_size_t vlen /**< length of a value */
); );
/** /**
@ -120,14 +120,14 @@ typedef void (*qse_lda_keeper_t) (
* when the array needs to be resized. * when the array needs to be resized.
*/ */
typedef qse_size_t (*qse_lda_sizer_t) ( typedef qse_size_t (*qse_lda_sizer_t) (
qse_lda_t* lda, /* a linear dynamic array */ qse_lda_t* lda, /**< array */
qse_size_t hint /* a sizing hint */ qse_size_t hint /**< sizing hint */
); );
typedef qse_lda_walk_t (*qse_lda_walker_t) ( typedef qse_lda_walk_t (*qse_lda_walker_t) (
qse_lda_t* lda /* a linear dynamic array */, qse_lda_t* lda /* array */,
qse_size_t index /* the index to the visited node */, qse_size_t index /* index to the visited node */,
void* arg /* user-defined data */ void* ctx /* user-defined context */
); );
/** /**
@ -167,16 +167,16 @@ QSE_DEFINE_COMMON_FUNCTIONS (lda)
* The qse_lda_open() function creates a linear dynamic array. * The qse_lda_open() function creates a linear dynamic array.
*/ */
qse_lda_t* qse_lda_open ( qse_lda_t* qse_lda_open (
qse_mmgr_t* lda, qse_mmgr_t* mmgr, /**< memory manager */
qse_size_t ext, qse_size_t ext, /**< extension size in bytes */
qse_size_t capa qse_size_t capa /**< initial array capacity */
); );
/** /**
* The qse_lda_close() function destroys a linear dynamic array. * The qse_lda_close() function destroys a linear dynamic array.
*/ */
void qse_lda_close ( void qse_lda_close (
qse_lda_t* lda qse_lda_t* lda /**< array */
); );
/** /**
@ -192,11 +192,14 @@ qse_lda_t* qse_lda_init (
* The qse_lda_fini() function finalizes a linear dynamic array. * The qse_lda_fini() function finalizes a linear dynamic array.
*/ */
void qse_lda_fini ( void qse_lda_fini (
qse_lda_t* lda qse_lda_t* lda /**< array */
); );
/**
* The qse_lda_getscale() function returns the scale factor
*/
int qse_lda_getscale ( int qse_lda_getscale (
qse_lda_t* lda /* lda */ qse_lda_t* lda /**< array */
); );
/** /**
@ -207,12 +210,12 @@ int qse_lda_getscale (
* It is a bad idea to change the scale factor when @a lda is not empty. * It is a bad idea to change the scale factor when @a lda is not empty.
*/ */
void qse_lda_setscale ( void qse_lda_setscale (
qse_lda_t* lda /* lda */, qse_lda_t* lda /**< array */,
int scale /* a scale factor */ int scale /**< scale factor */
); );
qse_lda_copier_t qse_lda_getcopier ( qse_lda_copier_t qse_lda_getcopier (
qse_lda_t* lda /* lda */ qse_lda_t* lda /* array */
); );
/** /**
@ -227,6 +230,9 @@ void qse_lda_setcopier (
qse_lda_copier_t copier /** element copier */ qse_lda_copier_t copier /** element copier */
); );
/**
* The qse_lda_getfreeer() function returns a custom element destroyer.
*/
qse_lda_freeer_t qse_lda_getfreeer ( qse_lda_freeer_t qse_lda_getfreeer (
qse_lda_t* lda /**< lda */ qse_lda_t* lda /**< lda */
); );

View File

@ -275,6 +275,9 @@ void qse_rbt_setcopier (
qse_rbt_copier_t copier /**< callback for copying a key or a value */ qse_rbt_copier_t copier /**< callback for copying a key or a value */
); );
/**
* The qse_rb_getfreeer() function returns the element destroyer.
*/
qse_rbt_freeer_t qse_rbt_getfreeer ( qse_rbt_freeer_t qse_rbt_getfreeer (
qse_rbt_t* rbt, /**< red-black tree */ qse_rbt_t* rbt, /**< red-black tree */
qse_rbt_id_t id /**< #QSE_RBT_KEY or #QSE_RBT_VAL */ qse_rbt_id_t id /**< #QSE_RBT_KEY or #QSE_RBT_VAL */

View File

@ -1,5 +1,5 @@
/* /*
* $Id: rex.h 328 2010-07-08 06:58:44Z hyunghwan.chung $ * $Id: rex.h 341 2010-08-04 07:25:48Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE. This file is part of QSE.
@ -181,7 +181,7 @@ enum qse_rex_cset_code_t
QSE_REX_CSET_CLASS QSE_REX_CSET_CLASS
}; };
/** /** @struct qse_rex_t
* The qse_rex_t type defines a regular expression processor. * The qse_rex_t type defines a regular expression processor.
* You can compile a regular expression and match it againt a string. * You can compile a regular expression and match it againt a string.
*/ */

View File

@ -1,5 +1,5 @@
/* /*
* $Id: str.h 324 2010-04-29 13:14:13Z hyunghwan.chung $ * $Id: str.h 341 2010-08-04 07:25:48Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE. This file is part of QSE.
@ -623,7 +623,7 @@ qse_char_t* qse_strtrmx (
int op /**< operation code XOR'ed of qse_strtrmx_op_t values */ int op /**< operation code XOR'ed of qse_strtrmx_op_t values */
); );
/* /**
* The qse_strtrm() function strips leading spaces and/or trailing * The qse_strtrm() function strips leading spaces and/or trailing
* spaces off a string. All characters between the first and the last non-space * spaces off a string. All characters between the first and the last non-space
* character inclusive are relocated to the beginning of memory pointed to * character inclusive are relocated to the beginning of memory pointed to
@ -634,7 +634,7 @@ qse_size_t qse_strtrm (
qse_char_t* str /**< string */ qse_char_t* str /**< string */
); );
/* /**
* The qse_strxtrm() function strips leading spaces and/or trailing * The qse_strxtrm() function strips leading spaces and/or trailing
* spaces off a string. All characters between the first and the last non-space * spaces off a string. All characters between the first and the last non-space
* character inclusive are relocated to the beginning of memory pointed to * character inclusive are relocated to the beginning of memory pointed to

View File

@ -31,7 +31,35 @@
# define QSE_XMA_ENABLE_STAT # define QSE_XMA_ENABLE_STAT
#endif #endif
/** @struct qse_xma_t
* The qse_xma_t type defines a simple memory allocator over a memory zone.
* It can obtain a relatively large zone of memory and manage it.
*
* @code
* qse_xma_t* xma;
* void* ptr1, * ptr2;
*
* // create a new memory allocator obtaining a 100K byte zone
* // with the default memory allocator
* xma = qse_xma_open (QSE_NULL, 0, 100000L);
*
* ptr1 = qse_xma_alloc (xma, 5000); // allocate a 5K block from the zone
* ptr2 = qse_xma_alloc (xma, 1000); // allocate a 1K block from the zone
* ptr1 = qse_xma_realloc (xma, ptr1, 6000); // resize the 5K block to 6K.
*
* qse_xma_dump (xma, qse_printf); // dump memory blocks
*
* qse_xma_free (xma, ptr2); // dispose of the 1K block
* qse_xma_free (xma, ptr1); // dispose of the 6K block
*
* qse_xma_close (xma); // destroy the memory allocator
* @endcode
*/
typedef struct qse_xma_t qse_xma_t; typedef struct qse_xma_t qse_xma_t;
/**
* The qse_xma_blk_t type defines a memory block allocated.
*/
typedef struct qse_xma_blk_t qse_xma_blk_t; typedef struct qse_xma_blk_t qse_xma_blk_t;
#define QSE_XMA_FIXED 32 #define QSE_XMA_FIXED 32
@ -41,8 +69,13 @@ struct qse_xma_t
{ {
QSE_DEFINE_COMMON_FIELDS (xma) QSE_DEFINE_COMMON_FIELDS (xma)
/** pointer to the first memory block */
qse_xma_blk_t* head; qse_xma_blk_t* head;
/** pointer array to free memory blocks */
qse_xma_blk_t* xfree[QSE_XMA_FIXED + QSE_XMA_SIZE_BITS + 1]; qse_xma_blk_t* xfree[QSE_XMA_FIXED + QSE_XMA_SIZE_BITS + 1];
/** pre-computed value for fast xfree index calculation */
qse_size_t bdec; qse_size_t bdec;
#ifdef QSE_XMA_ENABLE_STAT #ifdef QSE_XMA_ENABLE_STAT
@ -64,50 +97,87 @@ extern "C" {
QSE_DEFINE_COMMON_FUNCTIONS (xma) QSE_DEFINE_COMMON_FUNCTIONS (xma)
/** /**
* The qse_xma_open() function creates a memory allocator. * The qse_xma_open() function creates a memory allocator. It obtains a memory
* zone of the @a zonesize bytes with the memory manager @a mmgr. It also makes
* available the extension area of the @a xtnsize bytes that you can get the
* pointer to with qse_xma_getxtn().
*
* @return pointer to a memory allocator on success, #QSE_NULL on failure
*/ */
qse_xma_t* qse_xma_open ( qse_xma_t* qse_xma_open (
qse_mmgr_t* mmgr, qse_mmgr_t* mmgr, /**< memory manager */
qse_size_t ext, qse_size_t xtnsize, /**< extension size in bytes */
qse_size_t size qse_size_t zonesize /**< zone size in bytes */
); );
/**
* The qse_xma_close() function destroys a memory allocator. It also frees
* the memory zone obtained, which invalidates the memory blocks within
* the zone. Call this function to destroy a memory allocator created with
* qse_xma_open().
*/
void qse_xma_close ( void qse_xma_close (
qse_xma_t* xma qse_xma_t* xma /**< memory allocator */
); );
/**
* The qse_xma_init() initializes a memory allocator. If you have the qse_xma_t
* structure statically declared or already allocated, you may pass the pointer
* to this function instead of calling qse_xma_open(). It obtains a memory zone
* of @a zonesize bytes with the memory manager @mmgr. Unlike qse_xma_open(),
* it does not accept the extension size, thus not creating an extention area.
* @return @a xma on success, #QSE_NULL on failure
*/
qse_xma_t* qse_xma_init ( qse_xma_t* qse_xma_init (
qse_xma_t* xma, qse_xma_t* xma, /**< memory allocator */
qse_mmgr_t* mmgr, qse_mmgr_t* mmgr, /**< memory manager */
qse_size_t size qse_size_t zonesize /**< zone size in bytes */
); );
/**
* The qse_xma_fini() function finalizes a memory allocator. Call this
* function to finalize a memory allocator initialized with qse_xma_init().
*/
void qse_xma_fini ( void qse_xma_fini (
qse_xma_t* xma qse_xma_t* xma /**< memory allocator */
); );
/**
* The qse_xma_alloc() function allocates @a size bytes.
* @return pointer to a memory block on success, #QSE_NULL on failure
*/
void* qse_xma_alloc ( void* qse_xma_alloc (
qse_xma_t* xma, qse_xma_t* xma, /**< memory allocator */
qse_size_t size qse_size_t size /**< size in bytes */
); );
/**
* The qse_xma_alloc() function resizes the memory block @a b to @a size bytes.
* @return pointer to a resized memory block on success, #QSE_NULL on failure
*/
void* qse_xma_realloc ( void* qse_xma_realloc (
qse_xma_t* xma, qse_xma_t* xma, /**< memory allocator */
void* b, void* b, /**< memory block */
qse_size_t size qse_size_t size /**< new size in bytes */
); );
/**
* The qse_xma_alloc() function frees the memory block @a b.
*/
void qse_xma_free ( void qse_xma_free (
qse_xma_t* xma, qse_xma_t* xma, /**< memory allocator */
void* b void* b /**< memory block */
); );
/**
* The qse_xma_dump() function dumps the contents of the memory zone
* with the output function @a printf provided.
*/
void qse_xma_dump ( void qse_xma_dump (
qse_xma_t* xma, qse_xma_t* xma, /**< memory allocator */
int (*printf)(const qse_char_t* fmt,...) int (*printf)(const qse_char_t* fmt,...) /**< output function */
); );
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -104,7 +104,8 @@ static QSE_INLINE_ALWAYS qse_size_t getxfi (qse_xma_t* xma, qse_size_t size)
return xfi; return xfi;
} }
qse_xma_t* qse_xma_open (qse_mmgr_t* mmgr, qse_size_t ext, qse_size_t size) qse_xma_t* qse_xma_open (
qse_mmgr_t* mmgr, qse_size_t xtnsize, qse_size_t zonesize)
{ {
qse_xma_t* xma; qse_xma_t* xma;
@ -118,10 +119,10 @@ qse_xma_t* qse_xma_open (qse_mmgr_t* mmgr, qse_size_t ext, qse_size_t size)
if (mmgr == QSE_NULL) return QSE_NULL; if (mmgr == QSE_NULL) return QSE_NULL;
} }
xma = (qse_xma_t*) QSE_MMGR_ALLOC (mmgr, QSE_SIZEOF(*xma) + ext); xma = (qse_xma_t*) QSE_MMGR_ALLOC (mmgr, QSE_SIZEOF(*xma) + xtnsize);
if (xma == QSE_NULL) return QSE_NULL; if (xma == QSE_NULL) return QSE_NULL;
if (qse_xma_init (xma, mmgr, size) == QSE_NULL) if (qse_xma_init (xma, mmgr, zonesize) == QSE_NULL)
{ {
QSE_MMGR_FREE (mmgr, xma); QSE_MMGR_FREE (mmgr, xma);
return QSE_NULL; return QSE_NULL;
@ -136,22 +137,22 @@ void qse_xma_close (qse_xma_t* xma)
QSE_MMGR_FREE (xma->mmgr, xma); QSE_MMGR_FREE (xma->mmgr, xma);
} }
qse_xma_t* qse_xma_init (qse_xma_t* xma, qse_mmgr_t* mmgr, qse_size_t size) qse_xma_t* qse_xma_init (qse_xma_t* xma, qse_mmgr_t* mmgr, qse_size_t zonesize)
{ {
qse_xma_blk_t* free; qse_xma_blk_t* free;
qse_size_t xfi; qse_size_t xfi;
size = ((size + ALIGN - 1) / ALIGN) * ALIGN; zonesize = ((zonesize + ALIGN - 1) / ALIGN) * ALIGN;
/* adjust 'size' to be large enough to hold a single smallest block */ /* adjust 'zonesize' to be large enough to hold a single smallest block */
if (size < MINBLKLEN) size = MINBLKLEN; if (zonesize < MINBLKLEN) zonesize = MINBLKLEN;
/* allocate a memory chunk to use for actual memory allocation */ /* allocate a memory chunk to use for actual memory allocation */
free = QSE_MMGR_ALLOC (mmgr, size); free = QSE_MMGR_ALLOC (mmgr, zonesize);
if (free == QSE_NULL) return QSE_NULL; if (free == QSE_NULL) return QSE_NULL;
/* initialize the header part of the free chunk */ /* initialize the header part of the free chunk */
free->avail = 1; free->avail = 1;
free->size = size - HDRSIZE; /* size excluding the block header */ free->size = zonesize - HDRSIZE; /* size excluding the block header */
free->f.prev = QSE_NULL; free->f.prev = QSE_NULL;
free->f.next = QSE_NULL; free->f.next = QSE_NULL;
free->b.next = QSE_NULL; free->b.next = QSE_NULL;
@ -168,9 +169,9 @@ qse_xma_t* qse_xma_init (qse_xma_t* xma, qse_mmgr_t* mmgr, qse_size_t size)
/* initialize some statistical variables */ /* initialize some statistical variables */
#ifdef QSE_XMA_ENABLE_STAT #ifdef QSE_XMA_ENABLE_STAT
xma->stat.total = size; xma->stat.total = zonesize;
xma->stat.alloc = 0; xma->stat.alloc = 0;
xma->stat.avail = size - HDRSIZE; xma->stat.avail = zonesize - HDRSIZE;
xma->stat.nfree = 1; xma->stat.nfree = 1;
xma->stat.nused = 0; xma->stat.nused = 0;
#endif #endif