mirror of
https://github.com/michaelrsweet/mxml.git
synced 2024-11-24 03:15:30 +00:00
Add MXML_ALLOC_SIZE define (Issue #318)
This commit is contained in:
parent
0c97db4186
commit
002c34f458
@ -5,10 +5,12 @@ Changes in Mini-XML
|
|||||||
Changes in Mini-XML 4.0.3
|
Changes in Mini-XML 4.0.3
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
||||||
- The configure script now defaults the `DSOFLAGS` value to `LDFLAGS` if not
|
- Now default the `DSOFLAGS` value to `LDFLAGS` in the configure script
|
||||||
set (Issue #325)
|
(Issue #325)
|
||||||
- Now install the man page as "mxml4" to allow parallel installation of Mini-XML
|
- Now install the man page as "mxml4" to allow parallel installation of Mini-XML
|
||||||
4.x and 3.x (Issue #324)
|
4.x and 3.x (Issue #324)
|
||||||
|
- Added `MXML_ALLOC_SIZE` define to control the allocation increment for
|
||||||
|
attributes and indices (Issue #318)
|
||||||
- Fixed `mxmlSetDeclarationf` implementation (Issue #322)
|
- Fixed `mxmlSetDeclarationf` implementation (Issue #322)
|
||||||
|
|
||||||
|
|
||||||
|
12
mxml-attr.c
12
mxml-attr.c
@ -250,11 +250,15 @@ mxml_set_attr(mxml_node_t *node, // I - Element node
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add a new attribute...
|
// Add a new attribute...
|
||||||
if ((attr = realloc(node->value.element.attrs, (node->value.element.num_attrs + 1) * sizeof(_mxml_attr_t))) == NULL)
|
if ((node->value.element.num_attrs % MXML_ALLOC_SIZE) == 0)
|
||||||
return (false);
|
{
|
||||||
|
if ((attr = realloc(node->value.element.attrs, (node->value.element.num_attrs + MXML_ALLOC_SIZE) * sizeof(_mxml_attr_t))) == NULL)
|
||||||
|
return (false);
|
||||||
|
|
||||||
node->value.element.attrs = attr;
|
node->value.element.attrs = attr;
|
||||||
attr += node->value.element.num_attrs;
|
}
|
||||||
|
|
||||||
|
attr = node->value.element.attrs + node->value.element.num_attrs;
|
||||||
|
|
||||||
if ((attr->name = _mxml_strcopy(name)) == NULL)
|
if ((attr->name = _mxml_strcopy(name)) == NULL)
|
||||||
return (false);
|
return (false);
|
||||||
|
@ -247,7 +247,7 @@ mxmlIndexNew(mxml_node_t *node, // I - XML node tree
|
|||||||
{
|
{
|
||||||
if (ind->num_nodes >= ind->alloc_nodes)
|
if (ind->num_nodes >= ind->alloc_nodes)
|
||||||
{
|
{
|
||||||
if ((temp = realloc(ind->nodes, (ind->alloc_nodes + 64) * sizeof(mxml_node_t *))) == NULL)
|
if ((temp = realloc(ind->nodes, (ind->alloc_nodes + MXML_ALLOC_SIZE) * sizeof(mxml_node_t *))) == NULL)
|
||||||
{
|
{
|
||||||
// Unable to allocate memory for the index, so abort...
|
// Unable to allocate memory for the index, so abort...
|
||||||
mxmlIndexDelete(ind);
|
mxmlIndexDelete(ind);
|
||||||
@ -255,7 +255,7 @@ mxmlIndexNew(mxml_node_t *node, // I - XML node tree
|
|||||||
}
|
}
|
||||||
|
|
||||||
ind->nodes = temp;
|
ind->nodes = temp;
|
||||||
ind->alloc_nodes += 64;
|
ind->alloc_nodes += MXML_ALLOC_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ind->nodes[ind->num_nodes ++] = current;
|
ind->nodes[ind->num_nodes ++] = current;
|
||||||
|
@ -25,6 +25,9 @@
|
|||||||
# else
|
# else
|
||||||
# define MXML_DEBUG(...)
|
# define MXML_DEBUG(...)
|
||||||
# endif // DEBUG
|
# endif // DEBUG
|
||||||
|
# ifndef MXML_ALLOC_SIZE
|
||||||
|
# define MXML_ALLOC_SIZE 16 // Allocation increment
|
||||||
|
# endif // !MXML_ALLOC_SIZE
|
||||||
# define MXML_TAB 8 // Tabs every N columns
|
# define MXML_TAB 8 // Tabs every N columns
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user