diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2010-05-11 12:20:11 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2010-05-11 12:20:11 +0200 |
commit | 2e501c68a8641a2b3c430b55f13491a9c1c5d0f5 (patch) | |
tree | 49c2748443fe3c1f01108756b647440e0647a11b /libxsde/xsde/c/expat/xmlparse.c | |
parent | 161beba6cdb0d91b15ad19fa8b3e51d986203915 (diff) |
Add support for custom allocators
New example: examples/cxx/hybrid/allocator.
Diffstat (limited to 'libxsde/xsde/c/expat/xmlparse.c')
-rw-r--r-- | libxsde/xsde/c/expat/xmlparse.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/libxsde/xsde/c/expat/xmlparse.c b/libxsde/xsde/c/expat/xmlparse.c index 6eac810..19fa39a 100644 --- a/libxsde/xsde/c/expat/xmlparse.c +++ b/libxsde/xsde/c/expat/xmlparse.c @@ -12,6 +12,10 @@ #include "expat.h" +#ifdef XSDE_CUSTOM_ALLOCATOR +# include <xsde/allocator.h> +#endif + #ifdef XML_UNICODE #define XML_ENCODE_MAX XML_UTF16_ENCODE_MAX #define XmlConvert XmlUtf16Convert @@ -702,6 +706,16 @@ parserCreate(const XML_Char *encodingName, } else { XML_Memory_Handling_Suite *mtemp; + +#ifdef XSDE_CUSTOM_ALLOCATOR + parser = (XML_Parser)xsde_alloc(sizeof(struct XML_ParserStruct)); + if (parser != NULL) { + mtemp = (XML_Memory_Handling_Suite *)&(parser->m_mem); + mtemp->malloc_fcn = xsde_alloc; + mtemp->realloc_fcn = xsde_realloc; + mtemp->free_fcn = xsde_free; + } +#else parser = (XML_Parser)malloc(sizeof(struct XML_ParserStruct)); if (parser != NULL) { mtemp = (XML_Memory_Handling_Suite *)&(parser->m_mem); @@ -709,6 +723,7 @@ parserCreate(const XML_Char *encodingName, mtemp->realloc_fcn = realloc; mtemp->free_fcn = free; } +#endif } if (!parser) |