From 2e501c68a8641a2b3c430b55f13491a9c1c5d0f5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 11 May 2010 12:20:11 +0200 Subject: Add support for custom allocators New example: examples/cxx/hybrid/allocator. --- libxsde/xsde/allocator.c | 32 ++++++++++++++ libxsde/xsde/allocator.h | 27 ++++++++++++ libxsde/xsde/c/expat/xmlparse.c | 15 +++++++ libxsde/xsde/c/genx/genx.c | 18 ++++++++ libxsde/xsde/cxx/allocator.cxx | 26 +++++++++++ libxsde/xsde/cxx/allocator.hxx | 49 +++++++++++++++++++++ libxsde/xsde/cxx/allocator.ixx | 27 ++++++++++++ libxsde/xsde/cxx/buffer.cxx | 20 ++++++++- libxsde/xsde/cxx/buffer.ixx | 13 +++++- libxsde/xsde/cxx/hashmap.cxx | 31 ++++++++++++++ libxsde/xsde/cxx/hashmap.hxx | 2 + libxsde/xsde/cxx/hybrid/base.hxx | 27 ++++++++++-- libxsde/xsde/cxx/hybrid/cdr/istream.cxx | 13 +++++- libxsde/xsde/cxx/hybrid/cdr/istream.txx | 25 +++++++++++ libxsde/xsde/cxx/hybrid/sequence.hxx | 14 +++++- libxsde/xsde/cxx/hybrid/sequence.ixx | 50 ++++++++++++++++++++-- libxsde/xsde/cxx/hybrid/sequence.txx | 12 +++++- libxsde/xsde/cxx/hybrid/xdr/istream.cxx | 23 ++++++++-- libxsde/xsde/cxx/hybrid/xdr/istream.txx | 24 +++++++++++ libxsde/xsde/cxx/parser/expat/document.cxx | 16 +++++++ .../cxx/parser/non-validating/base64-binary.cxx | 35 +++++++++++++-- .../xsde/cxx/parser/non-validating/hex-binary.cxx | 33 +++++++++++++- libxsde/xsde/cxx/parser/non-validating/id-stl.cxx | 1 - .../xsde/cxx/parser/non-validating/idrefs-stl.cxx | 34 ++++++++++++++- libxsde/xsde/cxx/parser/non-validating/idrefs.cxx | 34 ++++++++++++++- .../xsde/cxx/parser/non-validating/ncname-stl.cxx | 1 - .../cxx/parser/non-validating/nmtokens-stl.cxx | 34 ++++++++++++++- .../xsde/cxx/parser/non-validating/nmtokens.cxx | 34 ++++++++++++++- libxsde/xsde/cxx/parser/non-validating/qname.cxx | 33 +++++++++++++- .../cxx/parser/non-validating/xml-schema-pskel.hxx | 3 +- libxsde/xsde/cxx/parser/substitution-map.cxx | 25 +++++++++++ .../xsde/cxx/parser/validating/base64-binary.cxx | 33 +++++++++++++- libxsde/xsde/cxx/parser/validating/hex-binary.cxx | 33 +++++++++++++- libxsde/xsde/cxx/parser/validating/idrefs-stl.cxx | 34 ++++++++++++++- libxsde/xsde/cxx/parser/validating/idrefs.cxx | 34 ++++++++++++++- .../xsde/cxx/parser/validating/inheritance-map.cxx | 25 +++++++++++ .../xsde/cxx/parser/validating/nmtokens-stl.cxx | 34 ++++++++++++++- libxsde/xsde/cxx/parser/validating/nmtokens.cxx | 34 ++++++++++++++- libxsde/xsde/cxx/parser/validating/qname.cxx | 33 +++++++++++++- .../cxx/parser/validating/xml-schema-pskel.hxx | 3 +- libxsde/xsde/cxx/qname.cxx | 20 +++++---- libxsde/xsde/cxx/qname.ixx | 17 ++++++++ libxsde/xsde/cxx/sequence-base.cxx | 27 +++++++++++- libxsde/xsde/cxx/sequence-base.ixx | 8 ++++ libxsde/xsde/cxx/serializer/context.cxx | 16 +++++++ .../serializer/non-validating/base64-binary.cxx | 24 +++++++++-- .../cxx/serializer/non-validating/hex-binary.cxx | 24 +++++++++-- libxsde/xsde/cxx/serializer/non-validating/id.cxx | 22 ++++++++-- .../xsde/cxx/serializer/non-validating/idref.cxx | 22 ++++++++-- .../cxx/serializer/non-validating/idrefs-stl.cxx | 24 +++++++++-- .../xsde/cxx/serializer/non-validating/idrefs.cxx | 25 +++++++++-- .../cxx/serializer/non-validating/language.cxx | 22 ++++++++-- .../xsde/cxx/serializer/non-validating/name.cxx | 22 ++++++++-- .../xsde/cxx/serializer/non-validating/ncname.cxx | 22 ++++++++-- .../xsde/cxx/serializer/non-validating/nmtoken.cxx | 22 ++++++++-- .../cxx/serializer/non-validating/nmtokens-stl.cxx | 24 +++++++++-- .../cxx/serializer/non-validating/nmtokens.cxx | 25 +++++++++-- .../non-validating/normalized-string-stl.cxx | 1 - .../non-validating/normalized-string.cxx | 23 ++++++++-- .../xsde/cxx/serializer/non-validating/qname.cxx | 24 +++++++++-- .../xsde/cxx/serializer/non-validating/string.cxx | 22 ++++++++-- .../xsde/cxx/serializer/non-validating/token.cxx | 22 ++++++++-- libxsde/xsde/cxx/serializer/non-validating/uri.cxx | 22 ++++++++-- libxsde/xsde/cxx/serializer/substitution-map.cxx | 49 ++++++++++++++++++++- .../cxx/serializer/validating/base64-binary.cxx | 24 +++++++++-- .../xsde/cxx/serializer/validating/hex-binary.cxx | 24 +++++++++-- libxsde/xsde/cxx/serializer/validating/id.cxx | 22 ++++++++-- libxsde/xsde/cxx/serializer/validating/idref.cxx | 22 ++++++++-- .../xsde/cxx/serializer/validating/idrefs-stl.cxx | 24 +++++++++-- libxsde/xsde/cxx/serializer/validating/idrefs.cxx | 25 +++++++++-- .../cxx/serializer/validating/inheritance-map.cxx | 25 +++++++++++ .../xsde/cxx/serializer/validating/language.cxx | 22 ++++++++-- libxsde/xsde/cxx/serializer/validating/name.cxx | 22 ++++++++-- libxsde/xsde/cxx/serializer/validating/ncname.cxx | 22 ++++++++-- libxsde/xsde/cxx/serializer/validating/nmtoken.cxx | 22 ++++++++-- .../cxx/serializer/validating/nmtokens-stl.cxx | 24 +++++++++-- .../xsde/cxx/serializer/validating/nmtokens.cxx | 25 +++++++++-- .../serializer/validating/normalized-string.cxx | 22 ++++++++-- libxsde/xsde/cxx/serializer/validating/qname.cxx | 24 +++++++++-- libxsde/xsde/cxx/serializer/validating/string.cxx | 22 ++++++++-- libxsde/xsde/cxx/serializer/validating/token.cxx | 22 ++++++++-- libxsde/xsde/cxx/serializer/validating/uri.cxx | 22 ++++++++-- libxsde/xsde/cxx/stack.cxx | 11 ++++- libxsde/xsde/cxx/stack.ixx | 13 +++++- libxsde/xsde/cxx/strdupx.cxx | 13 ++++++ libxsde/xsde/cxx/strdupx.hxx | 5 ++- libxsde/xsde/cxx/string-sequence.cxx | 19 ++++---- libxsde/xsde/cxx/string-sequence.ixx | 39 ++++++++++++++++- libxsde/xsde/cxx/string.cxx | 8 ++++ libxsde/xsde/cxx/string.ixx | 14 ++++++ libxsde/xsde/makefile | 24 +++++++++++ 91 files changed, 1900 insertions(+), 184 deletions(-) create mode 100644 libxsde/xsde/allocator.c create mode 100644 libxsde/xsde/allocator.h create mode 100644 libxsde/xsde/cxx/allocator.cxx create mode 100644 libxsde/xsde/cxx/allocator.hxx create mode 100644 libxsde/xsde/cxx/allocator.ixx (limited to 'libxsde') diff --git a/libxsde/xsde/allocator.c b/libxsde/xsde/allocator.c new file mode 100644 index 0000000..7874295 --- /dev/null +++ b/libxsde/xsde/allocator.c @@ -0,0 +1,32 @@ +// file : xsde/allocator.c +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// This is the default implementation of the custom allocator functions. +// It is primarily useful for testing when XSD/e is configured with custom +// allocators. You can also replace this implementation with your own if +// you would like to test with that. +// + +#include + +#include + +void* +xsde_alloc (size_t n) +{ + return malloc (n); +} + +void* +xsde_realloc (void* p, size_t n) +{ + return realloc (p, n); +} + +void +xsde_free (void* p) +{ + free (p); +} diff --git a/libxsde/xsde/allocator.h b/libxsde/xsde/allocator.h new file mode 100644 index 0000000..771f893 --- /dev/null +++ b/libxsde/xsde/allocator.h @@ -0,0 +1,27 @@ +// file : xsde/allocator.h +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_ALLOCATOR_HXX +#define XSDE_ALLOCATOR_HXX + +#include // size_t + +#ifdef __cplusplus +extern "C" +{ +#endif + +// Custom allocator functions. Your implementation should always return +// 0 on failure, regardless of whether exceptions are enabled or not. +// +void* xsde_alloc (size_t); +void* xsde_realloc (void*, size_t); +void xsde_free (void*); + +#ifdef __cplusplus +} +#endif + +#endif // XSDE_ALLOCATOR_HXX 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 +#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) diff --git a/libxsde/xsde/c/genx/genx.c b/libxsde/xsde/c/genx/genx.c index 0c0ed17..6596f81 100644 --- a/libxsde/xsde/c/genx/genx.c +++ b/libxsde/xsde/c/genx/genx.c @@ -10,8 +10,14 @@ #include #include +#include + #include "genx.h" +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + #define Boolean int #define True 1 #define False 0 @@ -156,7 +162,11 @@ static void * allocate(genxWriter w, int bytes) if (w->alloc) return (void *) (*w->alloc)(w->userData, bytes); else +#ifdef XSDE_CUSTOM_ALLOCATOR + return (void *) xsde_alloc(bytes); +#else return (void *) malloc(bytes); +#endif } static void deallocate(genxWriter w, void * data) @@ -164,7 +174,11 @@ static void deallocate(genxWriter w, void * data) if (w->dealloc) (*w->dealloc)(w->userData, data); else if (w->alloc == NULL) +#ifdef XSDE_CUSTOM_ALLOCATOR + xsde_free(data); +#else free(data); +#endif } static utf8 copy(genxWriter w, constUtf8 from) @@ -527,7 +541,11 @@ genxWriter genxNew(void * (* alloc)(void * userData, int bytes), if (alloc) w = (genxWriter) (*alloc)(userData, sizeof(struct genxWriter_rec)); else +#ifdef XSDE_CUSTOM_ALLOCATOR + w = (genxWriter) xsde_alloc(sizeof(struct genxWriter_rec)); +#else w = (genxWriter) malloc(sizeof(struct genxWriter_rec)); +#endif if (w == NULL) return NULL; diff --git a/libxsde/xsde/cxx/allocator.cxx b/libxsde/xsde/cxx/allocator.cxx new file mode 100644 index 0000000..0e7fb79 --- /dev/null +++ b/libxsde/xsde/cxx/allocator.cxx @@ -0,0 +1,26 @@ +// file : xsde/cxx/allocator.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include +#include + +namespace xsde +{ + namespace cxx + { +#ifdef XSDE_EXCEPTIONS + void* + alloc (size_t n) + { + void* p = xsde_alloc (n); + + if (p == 0) + throw std::bad_alloc (); + + return p; + } +#endif + } +} diff --git a/libxsde/xsde/cxx/allocator.hxx b/libxsde/xsde/cxx/allocator.hxx new file mode 100644 index 0000000..248ee55 --- /dev/null +++ b/libxsde/xsde/cxx/allocator.hxx @@ -0,0 +1,49 @@ +// file : xsde/cxx/allocator.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_ALLOCATOR_HXX +#define XSDE_CXX_ALLOCATOR_HXX + +#include // size_t +#include // placement new + +#include + +namespace xsde +{ + namespace cxx + { + // Allocate a memory block using custom allocator. If exceptions + // are enabled this function throws std::bad_alloc on failure. + // Otherwise it returns 0. + // + void* + alloc (size_t); + + void + free (void*); + +#ifdef XSDE_EXCEPTIONS + struct alloc_guard + { + alloc_guard (void* p) : p_ (p) {} + ~alloc_guard () { if (p_) cxx::free (p_); } + + void* + get () const { return p_; } + + void + release () { p_ = 0; } + + private: + void* p_; + }; +#endif + } +} + +#include + +#endif // XSDE_CXX_ALLOCATOR_HXX diff --git a/libxsde/xsde/cxx/allocator.ixx b/libxsde/xsde/cxx/allocator.ixx new file mode 100644 index 0000000..9f3d50b --- /dev/null +++ b/libxsde/xsde/cxx/allocator.ixx @@ -0,0 +1,27 @@ +// file : xsde/cxx/allocator.ixx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +namespace xsde +{ + namespace cxx + { +#ifndef XSDE_EXCEPTIONS + inline void* + alloc (size_t n) + { + return xsde_alloc (n); + } +#endif + + inline void + free (void* p) + { + if (p) + xsde_free (p); + } + } +} diff --git a/libxsde/xsde/cxx/buffer.cxx b/libxsde/xsde/cxx/buffer.cxx index fbaa809..d9102ae 100644 --- a/libxsde/xsde/cxx/buffer.cxx +++ b/libxsde/xsde/cxx/buffer.cxx @@ -88,13 +88,21 @@ namespace xsde } else { - char* data = reinterpret_cast (operator new (capacity)); +#ifndef XSDE_CUSTOM_ALLOCATOR + char* data = static_cast (operator new (capacity)); +#else + char* data = static_cast (alloc (capacity)); +#endif if (copy && size_ > 0) memcpy (data, data_, size_); if (data_) +#ifndef XSDE_CUSTOM_ALLOCATOR operator delete (data_); +#else + cxx::free (data_); +#endif data_ = data; capacity_ = capacity; @@ -118,7 +126,11 @@ namespace xsde } else { - char* data = reinterpret_cast (operator new (capacity)); +#ifndef XSDE_CUSTOM_ALLOCATOR + char* data = static_cast (operator new (capacity)); +#else + char* data = static_cast (alloc (capacity)); +#endif if (data != 0) { @@ -126,7 +138,11 @@ namespace xsde memcpy (data, data_, size_); if (data_) +#ifndef XSDE_CUSTOM_ALLOCATOR operator delete (data_); +#else + cxx::free (data_); +#endif data_ = data; capacity_ = capacity; diff --git a/libxsde/xsde/cxx/buffer.ixx b/libxsde/xsde/cxx/buffer.ixx index 51e3f07..2229396 100644 --- a/libxsde/xsde/cxx/buffer.ixx +++ b/libxsde/xsde/cxx/buffer.ixx @@ -5,6 +5,10 @@ #include // memcmp +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -15,7 +19,11 @@ namespace xsde ~buffer () { if (data_) +#ifndef XSDE_CUSTOM_ALLOCATOR operator delete (data_); +#else + cxx::free (data_); +#endif } inline buffer:: @@ -41,7 +49,11 @@ namespace xsde } if (data_) +#ifndef XSDE_CUSTOM_ALLOCATOR operator delete (data_); +#else + cxx::free (data_); +#endif data_ = reinterpret_cast (data); size_ = size; @@ -210,4 +222,3 @@ namespace xsde } } } - diff --git a/libxsde/xsde/cxx/hashmap.cxx b/libxsde/xsde/cxx/hashmap.cxx index b633cbd..f87ebbf 100644 --- a/libxsde/xsde/cxx/hashmap.cxx +++ b/libxsde/xsde/cxx/hashmap.cxx @@ -7,6 +7,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -76,10 +80,18 @@ namespace xsde for (size_t i = 0; i < bcount_; ++i) { if (buckets_[i]) +#ifndef XSDE_CUSTOM_ALLOCATOR operator delete (buckets_[i]); +#else + cxx::free (buckets_[i]); +#endif } +#ifndef XSDE_CUSTOM_ALLOCATOR delete[] buckets_; +#else + cxx::free (buckets_); // POD. +#endif #ifndef XSDE_EXCEPTIONS } @@ -95,7 +107,11 @@ namespace xsde error_ = error_none; #endif +#ifndef XSDE_CUSTOM_ALLOCATOR buckets_ = new bucket*[bcount_]; +#else + buckets_ = static_cast (alloc (bcount_ * sizeof (bucket*))); +#endif #ifndef XSDE_EXCEPTIONS if (buckets_ == 0) @@ -118,8 +134,13 @@ namespace xsde // No elements in this bucket yet. Start with capacity for 2 // elements. // +#ifndef XSDE_CUSTOM_ALLOCATOR p = static_cast ( operator new (sizeof (bucket) + 2 * (sizeof (element) + esize_))); +#else + p = static_cast ( + alloc (sizeof (bucket) + 2 * (sizeof (element) + esize_))); +#endif #ifndef XSDE_EXCEPTIONS if (p == 0) @@ -137,8 +158,14 @@ namespace xsde // No more space in this bucket. Create a bigger bucket. // size_t c = p->size_ * 2; + +#ifndef XSDE_CUSTOM_ALLOCATOR bucket* n = static_cast ( operator new (sizeof (bucket) + c * (sizeof (element) + esize_))); +#else + bucket* n = static_cast ( + alloc (sizeof (bucket) + c * (sizeof (element) + esize_))); +#endif #ifndef XSDE_EXCEPTIONS if (n == 0) @@ -155,7 +182,11 @@ namespace xsde memcpy (dst, src, p->size_ * (sizeof (element) + esize_)); +#ifndef XSDE_CUSTOM_ALLOCATOR operator delete (p); +#else + cxx::free (p); +#endif p = n; } diff --git a/libxsde/xsde/cxx/hashmap.hxx b/libxsde/xsde/cxx/hashmap.hxx index 9b85fa4..c2562e1 100644 --- a/libxsde/xsde/cxx/hashmap.hxx +++ b/libxsde/xsde/cxx/hashmap.hxx @@ -117,6 +117,8 @@ namespace xsde hash (size_t hash, const char*, size_t n); protected: + // Keep these types POD. + // struct bucket { size_t size_; diff --git a/libxsde/xsde/cxx/hybrid/base.hxx b/libxsde/xsde/cxx/hybrid/base.hxx index 1a238a1..89431a2 100644 --- a/libxsde/xsde/cxx/hybrid/base.hxx +++ b/libxsde/xsde/cxx/hybrid/base.hxx @@ -12,6 +12,10 @@ # include // strcmp #endif +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -566,17 +570,34 @@ namespace xsde struct string_base { string_base () : x_ (0) {} - ~string_base () {delete[] x_;} + ~string_base () + { +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] x_; +#else + cxx::free (x_); +#endif + } const char* base_value () const {return x_;} char* base_value () {return x_;} - void base_value (char* x) {delete[] x_; x_ = x;} + + void base_value (char* x) + { +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] x_; +#else + cxx::free (x_); +#endif + x_ = x; + } + char* base_value_detach () {char* r = x_; x_ = 0; return r;} operator const char* () const {return x_;} operator char* () {return x_;} - string_base& operator= (char* x) {delete[] x_; x_ = x; return *this;} + string_base& operator= (char* x) {base_value (x); return *this;} protected: char* x_; diff --git a/libxsde/xsde/cxx/hybrid/cdr/istream.cxx b/libxsde/xsde/cxx/hybrid/cdr/istream.cxx index 684df2d..06e26e6 100644 --- a/libxsde/xsde/cxx/hybrid/cdr/istream.cxx +++ b/libxsde/xsde/cxx/hybrid/cdr/istream.cxx @@ -17,7 +17,14 @@ namespace xsde struct str_guard { str_guard (char* s) : s_ (s) {} - ~str_guard () {delete[] s_;} + ~str_guard () + { +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] s_; +#else + cxx::free (s_); +#endif + } private: char* s_; @@ -70,7 +77,11 @@ namespace xsde return false; x = v; +#ifndef XSDE_CUSTOM_ALLOCATOR delete[] v; +#else + cxx::free (v); +#endif return true; } #else diff --git a/libxsde/xsde/cxx/hybrid/cdr/istream.txx b/libxsde/xsde/cxx/hybrid/cdr/istream.txx index 58cd98b..f1d8d6c 100644 --- a/libxsde/xsde/cxx/hybrid/cdr/istream.txx +++ b/libxsde/xsde/cxx/hybrid/cdr/istream.txx @@ -3,6 +3,10 @@ // copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -73,7 +77,14 @@ namespace xsde while (n--) { +#ifndef XSDE_CUSTOM_ALLOCATOR T* p = new T; +#else + T* p = static_cast (alloc (sizeof (T))); + alloc_guard pg (p); + new (p) T; + pg.release (); +#endif typename var_sequence::guard g (p); s >> *p; g.release (); @@ -159,14 +170,28 @@ namespace xsde while (n--) { +#ifndef XSDE_CUSTOM_ALLOCATOR T* p = new T; if (p == 0) return false; +#else + void* v = alloc (sizeof (T)); + + if (v == 0) + return false; + + T* p = new (v) T; // c-tor cannot fail +#endif if (!(s >> *p)) { +#ifndef XSDE_CUSTOM_ALLOCATOR delete p; +#else + p->~T (); + cxx::free (p); +#endif return false; } diff --git a/libxsde/xsde/cxx/hybrid/sequence.hxx b/libxsde/xsde/cxx/hybrid/sequence.hxx index 451c76d..fa5c697 100644 --- a/libxsde/xsde/cxx/hybrid/sequence.hxx +++ b/libxsde/xsde/cxx/hybrid/sequence.hxx @@ -22,6 +22,10 @@ # include #endif +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -831,7 +835,15 @@ namespace xsde public: struct guard { - ~guard () { delete p_; } + ~guard () + { +#ifndef XSDE_CUSTOM_ALLOCATOR + delete p_; +#else + cxx::free (p_); +#endif + } + guard (T* p) : p_ (p) {} void diff --git a/libxsde/xsde/cxx/hybrid/sequence.ixx b/libxsde/xsde/cxx/hybrid/sequence.ixx index 6029b76..1ec2a4c 100644 --- a/libxsde/xsde/cxx/hybrid/sequence.ixx +++ b/libxsde/xsde/cxx/hybrid/sequence.ixx @@ -551,7 +551,15 @@ namespace xsde inline void var_sequence:: pop_back () { - delete static_cast (data_)[size_ - 1]; + T* x = static_cast (data_)[size_ - 1]; + +#ifndef XSDE_CUSTOM_ALLOCATOR + delete x; +#else + if (x) + x->~T (); + cxx::free (x); +#endif --size_; } @@ -559,7 +567,15 @@ namespace xsde inline var_iterator var_sequence:: erase (iterator i) { - delete *i.i_; + T* x = *i.i_; + +#ifndef XSDE_CUSTOM_ALLOCATOR + delete x; +#else + if (x) + x->~T (); + cxx::free (x); +#endif if (i.i_ != static_cast (data_) + (size_ - 1)) erase_ (i.i_, sizeof (T*), 0); @@ -582,7 +598,15 @@ namespace xsde inline void var_sequence:: attach (iterator i, T* x) { - delete *i.i_; + T* t = *i.i_; + +#ifndef XSDE_CUSTOM_ALLOCATOR + delete t; +#else + if (t) + t->~T (); + cxx::free (t); +#endif *i.i_ = x; } @@ -632,7 +656,15 @@ namespace xsde if (r == error_none) static_cast (data_)[size_++] = x; else + { +#ifndef XSDE_CUSTOM_ALLOCATOR delete x; +#else + if (x) + x->~T (); + cxx::free (x); +#endif + } return r; } @@ -650,7 +682,13 @@ namespace xsde } else { +#ifndef XSDE_CUSTOM_ALLOCATOR delete x; +#else + if (x) + x->~T (); + cxx::free (x); +#endif return error_no_memory; } } @@ -669,7 +707,13 @@ namespace xsde } else { +#ifndef XSDE_CUSTOM_ALLOCATOR delete x; +#else + if (x) + x->~T (); + cxx::free (x); +#endif return error_no_memory; } } diff --git a/libxsde/xsde/cxx/hybrid/sequence.txx b/libxsde/xsde/cxx/hybrid/sequence.txx index 4fd3a85..b79e9d5 100644 --- a/libxsde/xsde/cxx/hybrid/sequence.txx +++ b/libxsde/xsde/cxx/hybrid/sequence.txx @@ -152,7 +152,17 @@ namespace xsde clear () { for (size_t i = 0; i < size_; ++i) - delete static_cast (data_)[i]; + { + T* x = static_cast (data_)[i]; + +#ifndef XSDE_CUSTOM_ALLOCATOR + delete x; +#else + if (x) + x->~T (); + cxx::free (x); +#endif + } size_ = 0; } diff --git a/libxsde/xsde/cxx/hybrid/xdr/istream.cxx b/libxsde/xsde/cxx/hybrid/xdr/istream.cxx index 2f870d0..e31fb7f 100644 --- a/libxsde/xsde/cxx/hybrid/xdr/istream.cxx +++ b/libxsde/xsde/cxx/hybrid/xdr/istream.cxx @@ -23,7 +23,7 @@ namespace xsde throw xdr_exception (); x.clear (); - + if (n != 0) { x.resize (n); @@ -42,11 +42,19 @@ namespace xsde if (!xdr_u_int (&xdr_, &n)) throw xdr_exception (); +#ifndef XSDE_CUSTOM_ALLOCATOR x = new char[n + 1]; +#else + x = static_cast (alloc (n + 1)); +#endif if (!xdr_opaque (&xdr_, x, n)) { +#ifndef XSDE_CUSTOM_ALLOCATOR delete[] x; +#else + cxx::free (x); +#endif throw xdr_exception (); } @@ -80,14 +88,14 @@ namespace xsde return false; x.clear (); - + if (n != 0) { x.resize (n); char* p = const_cast (x.c_str ()); return xdr_opaque (&xdr_, p, n); } - + return true; } #else @@ -99,14 +107,21 @@ namespace xsde if (!xdr_u_int (&xdr_, &n)) return false; +#ifndef XSDE_CUSTOM_ALLOCATOR x = new char[n + 1]; - +#else + x = static_cast (alloc (n + 1)); +#endif if (x == 0) return false; if (!xdr_opaque (&xdr_, x, n)) { +#ifndef XSDE_CUSTOM_ALLOCATOR delete[] x; +#else + cxx::free (x); +#endif return false; } diff --git a/libxsde/xsde/cxx/hybrid/xdr/istream.txx b/libxsde/xsde/cxx/hybrid/xdr/istream.txx index 8f1d646..876befd 100644 --- a/libxsde/xsde/cxx/hybrid/xdr/istream.txx +++ b/libxsde/xsde/cxx/hybrid/xdr/istream.txx @@ -3,6 +3,10 @@ // copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -73,7 +77,14 @@ namespace xsde while (n--) { +#ifndef XSDE_CUSTOM_ALLOCATOR T* p = new T; +#else + T* p = static_cast (alloc (sizeof (T))); + alloc_guard pg (p); + new (p) T; + pg.release (); +#endif typename var_sequence::guard g (p); s >> *p; g.release (); @@ -159,14 +170,27 @@ namespace xsde while (n--) { +#ifndef XSDE_CUSTOM_ALLOCATOR T* p = new T; if (p == 0) return false; +#else + void* v = alloc (sizeof (T)); + + if (v == 0) + return false; + T* p = new (v) T; // c-tor cannot fail +#endif if (!(s >> *p)) { +#ifndef XSDE_CUSTOM_ALLOCATOR delete p; +#else + p->~T (); + cxx::free (p); +#endif return false; } diff --git a/libxsde/xsde/cxx/parser/expat/document.cxx b/libxsde/xsde/cxx/parser/expat/document.cxx index 61cc1d0..84cf7f8 100644 --- a/libxsde/xsde/cxx/parser/expat/document.cxx +++ b/libxsde/xsde/cxx/parser/expat/document.cxx @@ -17,6 +17,10 @@ # include #endif +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + #ifdef XSDE_ENCODING_ISO8859_1 # include #endif @@ -1291,7 +1295,11 @@ namespace xsde buf = data_buf_; else { +#ifndef XSDE_CUSTOM_ALLOCATOR buf = new char[iso_n]; +#else + buf = static_cast (alloc (iso_n)); +#endif #ifndef XSDE_EXCEPTIONS if (buf == 0) @@ -1324,7 +1332,11 @@ namespace xsde buf = data_buf_; else { +#ifndef XSDE_CUSTOM_ALLOCATOR buf = new char[iso_n]; +#else + buf = static_cast (alloc (iso_n)); +#endif #ifndef XSDE_EXCEPTIONS if (buf == 0) @@ -1354,7 +1366,11 @@ namespace xsde buf = name_buf_; else { +#ifndef XSDE_CUSTOM_ALLOCATOR buf = new char[iso_n]; +#else + buf = static_cast (alloc (iso_n)); +#endif #ifndef XSDE_EXCEPTIONS if (buf == 0) diff --git a/libxsde/xsde/cxx/parser/non-validating/base64-binary.cxx b/libxsde/xsde/cxx/parser/non-validating/base64-binary.cxx index f84d2a4..fb90768 100644 --- a/libxsde/xsde/cxx/parser/non-validating/base64-binary.cxx +++ b/libxsde/xsde/cxx/parser/non-validating/base64-binary.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + #include static unsigned char @@ -34,11 +38,18 @@ namespace xsde { namespace non_validating { - base64_binary_pimpl:: + base64_binary_pimpl:: ~base64_binary_pimpl () { - if (!base_) + if (!base_ && buf_) + { +#ifndef XSDE_CUSTOM_ALLOCATOR delete buf_; +#else + buf_->~buffer (); + cxx::free (buf_); +#endif + } } void base64_binary_pimpl:: @@ -46,9 +57,14 @@ namespace xsde { base64_binary_pskel::_reset (); - if (!base_) + if (!base_ && buf_) { +#ifndef XSDE_CUSTOM_ALLOCATOR delete buf_; +#else + buf_->~buffer (); + cxx::free (buf_); +#endif buf_ = 0; } } @@ -70,7 +86,20 @@ namespace xsde { if (buf_ == 0) { +#ifndef XSDE_CUSTOM_ALLOCATOR buf_ = new buffer (); +#else + buf_ = static_cast (alloc (sizeof (buffer))); + +#ifdef XSDE_EXCEPTIONS + alloc_guard ag (buf_); + new (buf_) buffer (); + ag.release (); +#else + if (buf_) + new (buf_) buffer (); +#endif +#endif #ifndef XSDE_EXCEPTIONS if (buf_ == 0) diff --git a/libxsde/xsde/cxx/parser/non-validating/hex-binary.cxx b/libxsde/xsde/cxx/parser/non-validating/hex-binary.cxx index 530315e..83c578b 100644 --- a/libxsde/xsde/cxx/parser/non-validating/hex-binary.cxx +++ b/libxsde/xsde/cxx/parser/non-validating/hex-binary.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + #include static unsigned char @@ -33,8 +37,15 @@ namespace xsde hex_binary_pimpl:: ~hex_binary_pimpl () { - if (!base_) + if (!base_ && buf_) + { +#ifndef XSDE_CUSTOM_ALLOCATOR delete buf_; +#else + buf_->~buffer (); + cxx::free (buf_); +#endif + } } void hex_binary_pimpl:: @@ -42,9 +53,14 @@ namespace xsde { hex_binary_pskel::_reset (); - if (!base_) + if (!base_ && buf_) { +#ifndef XSDE_CUSTOM_ALLOCATOR delete buf_; +#else + buf_->~buffer (); + cxx::free (buf_); +#endif buf_ = 0; } } @@ -66,7 +82,20 @@ namespace xsde { if (buf_ == 0) { +#ifndef XSDE_CUSTOM_ALLOCATOR buf_ = new buffer (); +#else + buf_ = static_cast (alloc (sizeof (buffer))); + +#ifdef XSDE_EXCEPTIONS + alloc_guard ag (buf_); + new (buf_) buffer (); + ag.release (); +#else + if (buf_) + new (buf_) buffer (); +#endif +#endif #ifndef XSDE_EXCEPTIONS if (buf_ == 0) diff --git a/libxsde/xsde/cxx/parser/non-validating/id-stl.cxx b/libxsde/xsde/cxx/parser/non-validating/id-stl.cxx index 6c49ecf..2e5ebd7 100644 --- a/libxsde/xsde/cxx/parser/non-validating/id-stl.cxx +++ b/libxsde/xsde/cxx/parser/non-validating/id-stl.cxx @@ -47,4 +47,3 @@ namespace xsde } } } - diff --git a/libxsde/xsde/cxx/parser/non-validating/idrefs-stl.cxx b/libxsde/xsde/cxx/parser/non-validating/idrefs-stl.cxx index 7c2b30d..6ae0245 100644 --- a/libxsde/xsde/cxx/parser/non-validating/idrefs-stl.cxx +++ b/libxsde/xsde/cxx/parser/non-validating/idrefs-stl.cxx @@ -7,6 +7,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + #include namespace xsde @@ -20,8 +24,15 @@ namespace xsde idrefs_pimpl:: ~idrefs_pimpl () { - if (!base_) + if (!base_ && seq_) + { +#ifndef XSDE_CUSTOM_ALLOCATOR delete seq_; +#else + seq_->~string_sequence (); + cxx::free (seq_); +#endif + } } void idrefs_pimpl:: @@ -29,9 +40,14 @@ namespace xsde { idrefs_pskel::_reset (); - if (!base_) + if (!base_ && seq_) { +#ifndef XSDE_CUSTOM_ALLOCATOR delete seq_; +#else + seq_->~string_sequence (); + cxx::free (seq_); +#endif seq_ = 0; } @@ -55,7 +71,21 @@ namespace xsde { if (seq_ == 0) { +#ifndef XSDE_CUSTOM_ALLOCATOR seq_ = new string_sequence (); +#else + seq_ = static_cast ( + alloc (sizeof (string_sequence))); + +#ifdef XSDE_EXCEPTIONS + alloc_guard ag (seq_); + new (seq_) string_sequence (); + ag.release (); +#else + if (seq_) + new () string_sequence (); +#endif +#endif #ifndef XSDE_EXCEPTIONS if (seq_ == 0) diff --git a/libxsde/xsde/cxx/parser/non-validating/idrefs.cxx b/libxsde/xsde/cxx/parser/non-validating/idrefs.cxx index d9e2794..b559c81 100644 --- a/libxsde/xsde/cxx/parser/non-validating/idrefs.cxx +++ b/libxsde/xsde/cxx/parser/non-validating/idrefs.cxx @@ -7,6 +7,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + #include namespace xsde @@ -20,8 +24,15 @@ namespace xsde idrefs_pimpl:: ~idrefs_pimpl () { - if (!base_) + if (!base_ && seq_) + { +#ifndef XSDE_CUSTOM_ALLOCATOR delete seq_; +#else + seq_->~string_sequence (); + cxx::free (seq_); +#endif + } } void idrefs_pimpl:: @@ -29,9 +40,14 @@ namespace xsde { idrefs_pskel::_reset (); - if (!base_) + if (!base_ && seq_) { +#ifndef XSDE_CUSTOM_ALLOCATOR delete seq_; +#else + seq_->~string_sequence (); + cxx::free (seq_); +#endif seq_ = 0; } @@ -55,7 +71,21 @@ namespace xsde { if (seq_ == 0) { +#ifndef XSDE_CUSTOM_ALLOCATOR seq_ = new string_sequence (); +#else + seq_ = static_cast ( + alloc (sizeof (string_sequence))); + +#ifdef XSDE_EXCEPTIONS + alloc_guard ag (seq_); + new (seq_) string_sequence (); + ag.release (); +#else + if (seq_) + new () string_sequence (); +#endif +#endif #ifndef XSDE_EXCEPTIONS if (seq_ == 0) diff --git a/libxsde/xsde/cxx/parser/non-validating/ncname-stl.cxx b/libxsde/xsde/cxx/parser/non-validating/ncname-stl.cxx index f0b5202..0ab155e 100644 --- a/libxsde/xsde/cxx/parser/non-validating/ncname-stl.cxx +++ b/libxsde/xsde/cxx/parser/non-validating/ncname-stl.cxx @@ -47,4 +47,3 @@ namespace xsde } } } - diff --git a/libxsde/xsde/cxx/parser/non-validating/nmtokens-stl.cxx b/libxsde/xsde/cxx/parser/non-validating/nmtokens-stl.cxx index 07d1945..93aefce 100644 --- a/libxsde/xsde/cxx/parser/non-validating/nmtokens-stl.cxx +++ b/libxsde/xsde/cxx/parser/non-validating/nmtokens-stl.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + #include namespace xsde @@ -18,8 +22,15 @@ namespace xsde nmtokens_pimpl:: ~nmtokens_pimpl () { - if (!base_) + if (!base_ && seq_) + { +#ifndef XSDE_CUSTOM_ALLOCATOR delete seq_; +#else + seq_->~string_sequence (); + cxx::free (seq_); +#endif + } } void nmtokens_pimpl:: @@ -27,9 +38,14 @@ namespace xsde { nmtokens_pskel::_reset (); - if (!base_) + if (!base_ && seq_) { +#ifndef XSDE_CUSTOM_ALLOCATOR delete seq_; +#else + seq_->~string_sequence (); + cxx::free (seq_); +#endif seq_ = 0; } @@ -53,7 +69,21 @@ namespace xsde { if (seq_ == 0) { +#ifndef XSDE_CUSTOM_ALLOCATOR seq_ = new string_sequence (); +#else + seq_ = static_cast ( + alloc (sizeof (string_sequence))); + +#ifdef XSDE_EXCEPTIONS + alloc_guard ag (seq_); + new (seq_) string_sequence (); + ag.release (); +#else + if (seq_) + new () string_sequence (); +#endif +#endif #ifndef XSDE_EXCEPTIONS if (seq_ == 0) diff --git a/libxsde/xsde/cxx/parser/non-validating/nmtokens.cxx b/libxsde/xsde/cxx/parser/non-validating/nmtokens.cxx index 15a6254..c798b88 100644 --- a/libxsde/xsde/cxx/parser/non-validating/nmtokens.cxx +++ b/libxsde/xsde/cxx/parser/non-validating/nmtokens.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + #include namespace xsde @@ -18,8 +22,15 @@ namespace xsde nmtokens_pimpl:: ~nmtokens_pimpl () { - if (!base_) + if (!base_ && seq_) + { +#ifndef XSDE_CUSTOM_ALLOCATOR delete seq_; +#else + seq_->~string_sequence (); + cxx::free (seq_); +#endif + } } void nmtokens_pimpl:: @@ -27,9 +38,14 @@ namespace xsde { nmtokens_pskel::_reset (); - if (!base_) + if (!base_ && seq_) { +#ifndef XSDE_CUSTOM_ALLOCATOR delete seq_; +#else + seq_->~string_sequence (); + cxx::free (seq_); +#endif seq_ = 0; } @@ -53,7 +69,21 @@ namespace xsde { if (seq_ == 0) { +#ifndef XSDE_CUSTOM_ALLOCATOR seq_ = new string_sequence (); +#else + seq_ = static_cast ( + alloc (sizeof (string_sequence))); + +#ifdef XSDE_EXCEPTIONS + alloc_guard ag (seq_); + new (seq_) string_sequence (); + ag.release (); +#else + if (seq_) + new () string_sequence (); +#endif +#endif #ifndef XSDE_EXCEPTIONS if (seq_ == 0) diff --git a/libxsde/xsde/cxx/parser/non-validating/qname.cxx b/libxsde/xsde/cxx/parser/non-validating/qname.cxx index 9be5872..7d9f71d 100644 --- a/libxsde/xsde/cxx/parser/non-validating/qname.cxx +++ b/libxsde/xsde/cxx/parser/non-validating/qname.cxx @@ -6,6 +6,10 @@ #include #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + #include namespace xsde @@ -19,8 +23,15 @@ namespace xsde qname_pimpl:: ~qname_pimpl () { - if (!base_) + if (!base_ && qn_) + { +#ifndef XSDE_CUSTOM_ALLOCATOR delete qn_; +#else + qn_->~qname (); + cxx::free (qn_); +#endif + } } void qname_pimpl:: @@ -28,9 +39,14 @@ namespace xsde { qname_pskel::_reset (); - if (!base_) + if (!base_ && qn_) { +#ifndef XSDE_CUSTOM_ALLOCATOR delete qn_; +#else + qn_->~qname (); + cxx::free (qn_); +#endif qn_ = 0; } } @@ -52,7 +68,20 @@ namespace xsde { if (qn_ == 0) { +#ifndef XSDE_CUSTOM_ALLOCATOR qn_ = new qname (); +#else + qn_ = static_cast (alloc (sizeof (qname))); + +#ifdef XSDE_EXCEPTIONS + alloc_guard ag (qn_); + new (qn_) qname (); + ag.release (); +#else + if (qn_) + new (qn_) qname (); +#endif +#endif #ifndef XSDE_EXCEPTIONS if (qn_ == 0) diff --git a/libxsde/xsde/cxx/parser/non-validating/xml-schema-pskel.hxx b/libxsde/xsde/cxx/parser/non-validating/xml-schema-pskel.hxx index 5f28434..59469c6 100644 --- a/libxsde/xsde/cxx/parser/non-validating/xml-schema-pskel.hxx +++ b/libxsde/xsde/cxx/parser/non-validating/xml-schema-pskel.hxx @@ -548,7 +548,8 @@ namespace xsde // String-based types. If STL is disabled you are getting a C - // string that you have to delete with delete[]. + // string that you have to delete with delete[] (or custom + // deallocator if enabled). // struct string_pskel: simple_content { diff --git a/libxsde/xsde/cxx/parser/substitution-map.cxx b/libxsde/xsde/cxx/parser/substitution-map.cxx index a10770a..5cbe4a1 100644 --- a/libxsde/xsde/cxx/parser/substitution-map.cxx +++ b/libxsde/xsde/cxx/parser/substitution-map.cxx @@ -12,6 +12,10 @@ # include // exit #endif +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + #include #include @@ -174,7 +178,21 @@ namespace xsde { if (count == 0) { +#ifndef XSDE_CUSTOM_ALLOCATOR map = new substitution_map (XSDE_PARSER_SMAP_BUCKETS); +#else + map = static_cast ( + alloc (sizeof (substitution_map))); + +#ifdef XSDE_EXCEPTIONS + alloc_guard mg (map); + new (map) substitution_map (XSDE_PARSER_SMAP_BUCKETS); + mg.release (); +#else + if (map) + new (map) substitution_map (XSDE_PARSER_SMAP_BUCKETS); +#endif +#endif #ifndef XSDE_EXCEPTIONS if (map == 0 || map->_error () != substitution_map::error_none) @@ -197,7 +215,14 @@ namespace xsde ~substitution_map_init () { if (--count == 0) + { +#ifndef XSDE_CUSTOM_ALLOCATOR delete map; +#else + map->~substitution_map (); + cxx::free (map); +#endif + } } // substitution_map_entry diff --git a/libxsde/xsde/cxx/parser/validating/base64-binary.cxx b/libxsde/xsde/cxx/parser/validating/base64-binary.cxx index 3aac6f3..f36df5a 100644 --- a/libxsde/xsde/cxx/parser/validating/base64-binary.cxx +++ b/libxsde/xsde/cxx/parser/validating/base64-binary.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + #include static unsigned char @@ -37,8 +41,15 @@ namespace xsde base64_binary_pimpl:: ~base64_binary_pimpl () { - if (!base_) + if (!base_ && buf_) + { +#ifndef XSDE_CUSTOM_ALLOCATOR delete buf_; +#else + buf_->~buffer (); + cxx::free (buf_); +#endif + } } void base64_binary_pimpl:: @@ -46,9 +57,14 @@ namespace xsde { base64_binary_pskel::_reset (); - if (!base_) + if (!base_ && buf_) { +#ifndef XSDE_CUSTOM_ALLOCATOR delete buf_; +#else + buf_->~buffer (); + cxx::free (buf_); +#endif buf_ = 0; } } @@ -70,7 +86,20 @@ namespace xsde { if (buf_ == 0) { +#ifndef XSDE_CUSTOM_ALLOCATOR buf_ = new buffer (); +#else + buf_ = static_cast (alloc (sizeof (buffer))); + +#ifdef XSDE_EXCEPTIONS + alloc_guard ag (buf_); + new (buf_) buffer (); + ag.release (); +#else + if (buf_) + new (buf_) buffer (); +#endif +#endif #ifndef XSDE_EXCEPTIONS if (buf_ == 0) diff --git a/libxsde/xsde/cxx/parser/validating/hex-binary.cxx b/libxsde/xsde/cxx/parser/validating/hex-binary.cxx index 24035fa..f7e6139 100644 --- a/libxsde/xsde/cxx/parser/validating/hex-binary.cxx +++ b/libxsde/xsde/cxx/parser/validating/hex-binary.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + #include static unsigned char @@ -33,8 +37,15 @@ namespace xsde hex_binary_pimpl:: ~hex_binary_pimpl () { - if (!base_) + if (!base_ && buf_) + { +#ifndef XSDE_CUSTOM_ALLOCATOR delete buf_; +#else + buf_->~buffer (); + cxx::free (buf_); +#endif + } } void hex_binary_pimpl:: @@ -42,9 +53,14 @@ namespace xsde { hex_binary_pskel::_reset (); - if (!base_) + if (!base_ && buf_) { +#ifndef XSDE_CUSTOM_ALLOCATOR delete buf_; +#else + buf_->~buffer (); + cxx::free (buf_); +#endif buf_ = 0; } } @@ -66,7 +82,20 @@ namespace xsde { if (buf_ == 0) { +#ifndef XSDE_CUSTOM_ALLOCATOR buf_ = new buffer (); +#else + buf_ = static_cast (alloc (sizeof (buffer))); + +#ifdef XSDE_EXCEPTIONS + alloc_guard ag (buf_); + new (buf_) buffer (); + ag.release (); +#else + if (buf_) + new (buf_) buffer (); +#endif +#endif #ifndef XSDE_EXCEPTIONS if (buf_ == 0) diff --git a/libxsde/xsde/cxx/parser/validating/idrefs-stl.cxx b/libxsde/xsde/cxx/parser/validating/idrefs-stl.cxx index 85129ed..3fc3175 100644 --- a/libxsde/xsde/cxx/parser/validating/idrefs-stl.cxx +++ b/libxsde/xsde/cxx/parser/validating/idrefs-stl.cxx @@ -7,6 +7,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + #include namespace xsde @@ -20,8 +24,15 @@ namespace xsde idrefs_pimpl:: ~idrefs_pimpl () { - if (!base_) + if (!base_ && seq_) + { +#ifndef XSDE_CUSTOM_ALLOCATOR delete seq_; +#else + seq_->~string_sequence (); + cxx::free (seq_); +#endif + } } void idrefs_pimpl:: @@ -29,9 +40,14 @@ namespace xsde { idrefs_pskel::_reset (); - if (!base_) + if (!base_ && seq_) { +#ifndef XSDE_CUSTOM_ALLOCATOR delete seq_; +#else + seq_->~string_sequence (); + cxx::free (seq_); +#endif seq_ = 0; } @@ -55,7 +71,21 @@ namespace xsde { if (seq_ == 0) { +#ifndef XSDE_CUSTOM_ALLOCATOR seq_ = new string_sequence (); +#else + seq_ = static_cast ( + alloc (sizeof (string_sequence))); + +#ifdef XSDE_EXCEPTIONS + alloc_guard ag (seq_); + new (seq_) string_sequence (); + ag.release (); +#else + if (seq_) + new () string_sequence (); +#endif +#endif #ifndef XSDE_EXCEPTIONS if (seq_ == 0) diff --git a/libxsde/xsde/cxx/parser/validating/idrefs.cxx b/libxsde/xsde/cxx/parser/validating/idrefs.cxx index 2bf35d2..851d28c 100644 --- a/libxsde/xsde/cxx/parser/validating/idrefs.cxx +++ b/libxsde/xsde/cxx/parser/validating/idrefs.cxx @@ -7,6 +7,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + #include namespace xsde @@ -20,8 +24,15 @@ namespace xsde idrefs_pimpl:: ~idrefs_pimpl () { - if (!base_) + if (!base_ && seq_) + { +#ifndef XSDE_CUSTOM_ALLOCATOR delete seq_; +#else + seq_->~string_sequence (); + cxx::free (seq_); +#endif + } } void idrefs_pimpl:: @@ -29,9 +40,14 @@ namespace xsde { idrefs_pskel::_reset (); - if (!base_) + if (!base_ && seq_) { +#ifndef XSDE_CUSTOM_ALLOCATOR delete seq_; +#else + seq_->~string_sequence (); + cxx::free (seq_); +#endif seq_ = 0; } @@ -55,7 +71,21 @@ namespace xsde { if (seq_ == 0) { +#ifndef XSDE_CUSTOM_ALLOCATOR seq_ = new string_sequence (); +#else + seq_ = static_cast ( + alloc (sizeof (string_sequence))); + +#ifdef XSDE_EXCEPTIONS + alloc_guard ag (seq_); + new (seq_) string_sequence (); + ag.release (); +#else + if (seq_) + new () string_sequence (); +#endif +#endif #ifndef XSDE_EXCEPTIONS if (seq_ == 0) diff --git a/libxsde/xsde/cxx/parser/validating/inheritance-map.cxx b/libxsde/xsde/cxx/parser/validating/inheritance-map.cxx index c3b9e41..f23e841 100644 --- a/libxsde/xsde/cxx/parser/validating/inheritance-map.cxx +++ b/libxsde/xsde/cxx/parser/validating/inheritance-map.cxx @@ -12,6 +12,10 @@ # include // exit #endif +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + #include #include @@ -50,7 +54,21 @@ namespace xsde { if (count == 0) { +#ifndef XSDE_CUSTOM_ALLOCATOR map = new inheritance_map (XSDE_PARSER_IMAP_BUCKETS); +#else + map = static_cast ( + alloc (sizeof (inheritance_map))); + +#ifdef XSDE_EXCEPTIONS + alloc_guard mg (map); + new (map) inheritance_map (XSDE_PARSER_IMAP_BUCKETS); + mg.release (); +#else + if (map) + new (map) inheritance_map (XSDE_PARSER_IMAP_BUCKETS); +#endif +#endif #ifndef XSDE_EXCEPTIONS if (map == 0 || map->_error () != inheritance_map::error_none) @@ -73,7 +91,14 @@ namespace xsde ~inheritance_map_init () { if (--count == 0) + { +#ifndef XSDE_CUSTOM_ALLOCATOR delete map; +#else + map->~inheritance_map (); + cxx::free (map); +#endif + } } // inheritance_map_entry diff --git a/libxsde/xsde/cxx/parser/validating/nmtokens-stl.cxx b/libxsde/xsde/cxx/parser/validating/nmtokens-stl.cxx index 8410d89..6258e26 100644 --- a/libxsde/xsde/cxx/parser/validating/nmtokens-stl.cxx +++ b/libxsde/xsde/cxx/parser/validating/nmtokens-stl.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + #include namespace xsde @@ -18,8 +22,15 @@ namespace xsde nmtokens_pimpl:: ~nmtokens_pimpl () { - if (!base_) + if (!base_ && seq_) + { +#ifndef XSDE_CUSTOM_ALLOCATOR delete seq_; +#else + seq_->~string_sequence (); + cxx::free (seq_); +#endif + } } void nmtokens_pimpl:: @@ -27,9 +38,14 @@ namespace xsde { nmtokens_pskel::_reset (); - if (!base_) + if (!base_ && seq_) { +#ifndef XSDE_CUSTOM_ALLOCATOR delete seq_; +#else + seq_->~string_sequence (); + cxx::free (seq_); +#endif seq_ = 0; } @@ -53,7 +69,21 @@ namespace xsde { if (seq_ == 0) { +#ifndef XSDE_CUSTOM_ALLOCATOR seq_ = new string_sequence (); +#else + seq_ = static_cast ( + alloc (sizeof (string_sequence))); + +#ifdef XSDE_EXCEPTIONS + alloc_guard ag (seq_); + new (seq_) string_sequence (); + ag.release (); +#else + if (seq_) + new () string_sequence (); +#endif +#endif #ifndef XSDE_EXCEPTIONS if (seq_ == 0) diff --git a/libxsde/xsde/cxx/parser/validating/nmtokens.cxx b/libxsde/xsde/cxx/parser/validating/nmtokens.cxx index 7573f28..5d06ef1 100644 --- a/libxsde/xsde/cxx/parser/validating/nmtokens.cxx +++ b/libxsde/xsde/cxx/parser/validating/nmtokens.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + #include namespace xsde @@ -18,8 +22,15 @@ namespace xsde nmtokens_pimpl:: ~nmtokens_pimpl () { - if (!base_) + if (!base_ && seq_) + { +#ifndef XSDE_CUSTOM_ALLOCATOR delete seq_; +#else + seq_->~string_sequence (); + cxx::free (seq_); +#endif + } } void nmtokens_pimpl:: @@ -27,9 +38,14 @@ namespace xsde { nmtokens_pskel::_reset (); - if (!base_) + if (!base_ && seq_) { +#ifndef XSDE_CUSTOM_ALLOCATOR delete seq_; +#else + seq_->~string_sequence (); + cxx::free (seq_); +#endif seq_ = 0; } @@ -53,7 +69,21 @@ namespace xsde { if (seq_ == 0) { +#ifndef XSDE_CUSTOM_ALLOCATOR seq_ = new string_sequence (); +#else + seq_ = static_cast ( + alloc (sizeof (string_sequence))); + +#ifdef XSDE_EXCEPTIONS + alloc_guard ag (seq_); + new (seq_) string_sequence (); + ag.release (); +#else + if (seq_) + new () string_sequence (); +#endif +#endif #ifndef XSDE_EXCEPTIONS if (seq_ == 0) diff --git a/libxsde/xsde/cxx/parser/validating/qname.cxx b/libxsde/xsde/cxx/parser/validating/qname.cxx index b98c8e9..5709824 100644 --- a/libxsde/xsde/cxx/parser/validating/qname.cxx +++ b/libxsde/xsde/cxx/parser/validating/qname.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + #include #include @@ -20,8 +24,15 @@ namespace xsde qname_pimpl:: ~qname_pimpl () { - if (!base_) + if (!base_ && qn_) + { +#ifndef XSDE_CUSTOM_ALLOCATOR delete qn_; +#else + qn_->~qname (); + cxx::free (qn_); +#endif + } } void qname_pimpl:: @@ -29,9 +40,14 @@ namespace xsde { qname_pskel::_reset (); - if (!base_) + if (!base_ && qn_) { +#ifndef XSDE_CUSTOM_ALLOCATOR delete qn_; +#else + qn_->~qname (); + cxx::free (qn_); +#endif qn_ = 0; } } @@ -53,7 +69,20 @@ namespace xsde { if (qn_ == 0) { +#ifndef XSDE_CUSTOM_ALLOCATOR qn_ = new qname (); +#else + qn_ = static_cast (alloc (sizeof (qname))); + +#ifdef XSDE_EXCEPTIONS + alloc_guard ag (qn_); + new (qn_) qname (); + ag.release (); +#else + if (qn_) + new (qn_) qname (); +#endif +#endif #ifndef XSDE_EXCEPTIONS if (qn_ == 0) diff --git a/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.hxx b/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.hxx index a978c6d..4b6b126 100644 --- a/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.hxx +++ b/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.hxx @@ -655,7 +655,8 @@ namespace xsde // // String-based types. If STL is disabled you are getting a C - // string that you have to delete with delete[]. + // string that you have to delete with delete[] (or custom + // deallocator if enabled). // struct string_facets diff --git a/libxsde/xsde/cxx/qname.cxx b/libxsde/xsde/cxx/qname.cxx index bd5e1c2..be196be 100644 --- a/libxsde/xsde/cxx/qname.cxx +++ b/libxsde/xsde/cxx/qname.cxx @@ -3,9 +3,7 @@ // copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file -#include // strlen, memcpy -#include // size_t - +#include #include namespace xsde @@ -19,18 +17,20 @@ namespace xsde #endif prefix_copy (const char* prefix) { +#ifndef XSDE_CUSTOM_ALLOCATOR delete[] prefix_; +#else + cxx::free (prefix_); +#endif if (prefix) { - size_t size = strlen (prefix) + 1; - prefix_ = new char[size]; + prefix_ = strdupx (prefix); #ifndef XSDE_EXCEPTIONS if (prefix_ == 0) return error_no_memory; #endif - memcpy (prefix_, prefix, size); } else prefix_ = 0; @@ -47,18 +47,20 @@ namespace xsde #endif name_copy (const char* name) { +#ifndef XSDE_CUSTOM_ALLOCATOR delete[] name_; +#else + cxx::free (name_); +#endif if (name) { - size_t size = strlen (name) + 1; - name_ = new char[size]; + name_ = strdupx (name); #ifndef XSDE_EXCEPTIONS if (name_ == 0) return error_no_memory; #endif - memcpy (name_, name, size); } else name_ = 0; diff --git a/libxsde/xsde/cxx/qname.ixx b/libxsde/xsde/cxx/qname.ixx index c46802d..f449ef3 100644 --- a/libxsde/xsde/cxx/qname.ixx +++ b/libxsde/xsde/cxx/qname.ixx @@ -5,6 +5,10 @@ #include // strcmp +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -14,8 +18,13 @@ namespace xsde inline qname:: ~qname () { +#ifndef XSDE_CUSTOM_ALLOCATOR delete[] prefix_; delete[] name_; +#else + cxx::free (prefix_); + cxx::free (name_); +#endif } inline qname:: @@ -66,7 +75,11 @@ namespace xsde inline void qname:: prefix (char* prefix) { +#ifndef XSDE_CUSTOM_ALLOCATOR delete[] prefix_; +#else + cxx::free (prefix_); +#endif prefix_ = prefix; } @@ -95,7 +108,11 @@ namespace xsde inline void qname:: name (char* name) { +#ifndef XSDE_CUSTOM_ALLOCATOR delete[] name_; +#else + cxx::free (name_); +#endif name_ = name; } diff --git a/libxsde/xsde/cxx/sequence-base.cxx b/libxsde/xsde/cxx/sequence-base.cxx index d2099a3..06d4012 100644 --- a/libxsde/xsde/cxx/sequence-base.cxx +++ b/libxsde/xsde/cxx/sequence-base.cxx @@ -29,7 +29,15 @@ namespace xsde struct guard { guard (void* p) : p_ (p) {} - ~guard () {if (p_) operator delete (p_);} + ~guard () + { + if (p_) +#ifndef XSDE_CUSTOM_ALLOCATOR + operator delete (p_); +#else + cxx::free (p_); +#endif + } void release () { p_ = 0; } @@ -42,7 +50,12 @@ namespace xsde grow_ (size_t n, size_t es, move_func mv) { size_t c = n == 0 ? (capacity_ != 0 ? capacity_ * 2 : 8) : n; + +#ifndef XSDE_CUSTOM_ALLOCATOR void* d = operator new (c * es); +#else + void* d = alloc (c * es); +#endif if (size_) { @@ -57,7 +70,11 @@ namespace xsde } if (data_) +#ifndef XSDE_CUSTOM_ALLOCATOR operator delete (data_); +#else + cxx::free (data_); +#endif data_ = d; capacity_ = c; @@ -89,7 +106,11 @@ namespace xsde grow_ (size_t n, size_t es, move_func mv) { size_t c = n == 0 ? (capacity_ != 0 ? capacity_ * 2 : 8) : n; +#ifndef XSDE_CUSTOM_ALLOCATOR void* d = operator new (c * es); +#else + void* d = alloc (c * es); +#endif if (d == 0) return error_no_memory; @@ -103,7 +124,11 @@ namespace xsde } if (data_) +#ifndef XSDE_CUSTOM_ALLOCATOR operator delete (data_); +#else + cxx::free (data_); +#endif data_ = d; capacity_ = c; diff --git a/libxsde/xsde/cxx/sequence-base.ixx b/libxsde/xsde/cxx/sequence-base.ixx index e4e446b..164feb4 100644 --- a/libxsde/xsde/cxx/sequence-base.ixx +++ b/libxsde/xsde/cxx/sequence-base.ixx @@ -3,6 +3,10 @@ // copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -17,7 +21,11 @@ namespace xsde ~sequence_base () { if (data_) +#ifndef XSDE_CUSTOM_ALLOCATOR operator delete (data_); +#else + cxx::free (data_); +#endif } inline bool sequence_base:: diff --git a/libxsde/xsde/cxx/serializer/context.cxx b/libxsde/xsde/cxx/serializer/context.cxx index faa1ed4..0a53c74 100644 --- a/libxsde/xsde/cxx/serializer/context.cxx +++ b/libxsde/xsde/cxx/serializer/context.cxx @@ -13,6 +13,10 @@ # include #endif +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + #ifdef XSDE_ENCODING_ISO8859_1 # include #endif @@ -738,7 +742,11 @@ namespace xsde buf = data_buf_; else { +#ifndef XSDE_CUSTOM_ALLOCATOR buf = new char[utf_n]; +#else + buf = static_cast (alloc (utf_n)); +#endif #ifndef XSDE_EXCEPTIONS if (buf == 0) @@ -763,7 +771,11 @@ namespace xsde buf = data_buf_; else { +#ifndef XSDE_CUSTOM_ALLOCATOR buf = new char[utf_n]; +#else + buf = static_cast (alloc (utf_n)); +#endif #ifndef XSDE_EXCEPTIONS if (buf == 0) @@ -788,7 +800,11 @@ namespace xsde buf = fix; else { +#ifndef XSDE_CUSTOM_ALLOCATOR buf = new char[utf_n]; +#else + buf = static_cast (alloc (utf_n)); +#endif #ifndef XSDE_EXCEPTIONS if (buf == 0) diff --git a/libxsde/xsde/cxx/serializer/non-validating/base64-binary.cxx b/libxsde/xsde/cxx/serializer/non-validating/base64-binary.cxx index 89afb12..180823e 100644 --- a/libxsde/xsde/cxx/serializer/non-validating/base64-binary.cxx +++ b/libxsde/xsde/cxx/serializer/non-validating/base64-binary.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -16,8 +20,16 @@ namespace xsde base64_binary_simpl:: ~base64_binary_simpl () { - if (free_) - delete const_cast (value_); + if (free_ && value_) + { + buffer* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete v; +#else + v->~buffer (); + cxx::free (v); +#endif + } } void base64_binary_simpl:: @@ -156,7 +168,13 @@ namespace xsde if (free_) { - delete const_cast (value_); + buffer* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete v; +#else + v->~buffer (); + cxx::free (v); +#endif value_ = 0; } } diff --git a/libxsde/xsde/cxx/serializer/non-validating/hex-binary.cxx b/libxsde/xsde/cxx/serializer/non-validating/hex-binary.cxx index 9c5a49c..36d3e32 100644 --- a/libxsde/xsde/cxx/serializer/non-validating/hex-binary.cxx +++ b/libxsde/xsde/cxx/serializer/non-validating/hex-binary.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -16,8 +20,16 @@ namespace xsde hex_binary_simpl:: ~hex_binary_simpl () { - if (free_) - delete const_cast (value_); + if (free_ && value_) + { + buffer* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete v; +#else + v->~buffer (); + cxx::free (v); +#endif + } } void hex_binary_simpl:: @@ -60,7 +72,13 @@ namespace xsde if (free_) { - delete const_cast (value_); + buffer* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete v; +#else + v->~buffer (); + cxx::free (v); +#endif value_ = 0; } } diff --git a/libxsde/xsde/cxx/serializer/non-validating/id.cxx b/libxsde/xsde/cxx/serializer/non-validating/id.cxx index db50bef..ac7ede2 100644 --- a/libxsde/xsde/cxx/serializer/non-validating/id.cxx +++ b/libxsde/xsde/cxx/serializer/non-validating/id.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -16,8 +20,15 @@ namespace xsde id_simpl:: ~id_simpl () { - if (free_) - delete[] const_cast (value_); + if (free_ && value_) + { + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif + } } void id_simpl:: @@ -33,7 +44,12 @@ namespace xsde if (free_) { - delete[] const_cast (value_); + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif value_ = 0; } } diff --git a/libxsde/xsde/cxx/serializer/non-validating/idref.cxx b/libxsde/xsde/cxx/serializer/non-validating/idref.cxx index c4022e7..e52650f 100644 --- a/libxsde/xsde/cxx/serializer/non-validating/idref.cxx +++ b/libxsde/xsde/cxx/serializer/non-validating/idref.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -16,8 +20,15 @@ namespace xsde idref_simpl:: ~idref_simpl () { - if (free_) - delete[] const_cast (value_); + if (free_ && value_) + { + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif + } } void idref_simpl:: @@ -33,7 +44,12 @@ namespace xsde if (free_) { - delete[] const_cast (value_); + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif value_ = 0; } } diff --git a/libxsde/xsde/cxx/serializer/non-validating/idrefs-stl.cxx b/libxsde/xsde/cxx/serializer/non-validating/idrefs-stl.cxx index ab48695..b95719a 100644 --- a/libxsde/xsde/cxx/serializer/non-validating/idrefs-stl.cxx +++ b/libxsde/xsde/cxx/serializer/non-validating/idrefs-stl.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -16,8 +20,16 @@ namespace xsde idrefs_simpl:: ~idrefs_simpl () { - if (free_) - delete const_cast (value_); + if (free_ && value_) + { + string_sequence* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete v; +#else + v->~string_sequence (); + cxx::free (v); +#endif + } } void idrefs_simpl:: @@ -91,7 +103,13 @@ namespace xsde if (free_) { - delete const_cast (value_); + string_sequence* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete v; +#else + v->~string_sequence (); + cxx::free (v); +#endif value_ = 0; } } diff --git a/libxsde/xsde/cxx/serializer/non-validating/idrefs.cxx b/libxsde/xsde/cxx/serializer/non-validating/idrefs.cxx index 11261a6..f812526 100644 --- a/libxsde/xsde/cxx/serializer/non-validating/idrefs.cxx +++ b/libxsde/xsde/cxx/serializer/non-validating/idrefs.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -16,8 +20,16 @@ namespace xsde idrefs_simpl:: ~idrefs_simpl () { - if (free_) - delete const_cast (value_); + if (free_ && value_) + { + string_sequence* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete v; +#else + v->~string_sequence (); + cxx::free (v); +#endif + } } void idrefs_simpl:: @@ -91,7 +103,13 @@ namespace xsde if (free_) { - delete const_cast (value_); + string_sequence* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete v; +#else + v->~string_sequence (); + cxx::free (v); +#endif value_ = 0; } } @@ -106,4 +124,3 @@ namespace xsde } } } - diff --git a/libxsde/xsde/cxx/serializer/non-validating/language.cxx b/libxsde/xsde/cxx/serializer/non-validating/language.cxx index 72ccd8b..801aa3a 100644 --- a/libxsde/xsde/cxx/serializer/non-validating/language.cxx +++ b/libxsde/xsde/cxx/serializer/non-validating/language.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -16,8 +20,15 @@ namespace xsde language_simpl:: ~language_simpl () { - if (free_) - delete[] const_cast (value_); + if (free_ && value_) + { + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif + } } void language_simpl:: @@ -33,7 +44,12 @@ namespace xsde if (free_) { - delete[] const_cast (value_); + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif value_ = 0; } } diff --git a/libxsde/xsde/cxx/serializer/non-validating/name.cxx b/libxsde/xsde/cxx/serializer/non-validating/name.cxx index 851dcf9..6e8e0b1 100644 --- a/libxsde/xsde/cxx/serializer/non-validating/name.cxx +++ b/libxsde/xsde/cxx/serializer/non-validating/name.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -16,8 +20,15 @@ namespace xsde name_simpl:: ~name_simpl () { - if (free_) - delete[] const_cast (value_); + if (free_ && value_) + { + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif + } } void name_simpl:: @@ -33,7 +44,12 @@ namespace xsde if (free_) { - delete[] const_cast (value_); + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif value_ = 0; } } diff --git a/libxsde/xsde/cxx/serializer/non-validating/ncname.cxx b/libxsde/xsde/cxx/serializer/non-validating/ncname.cxx index 3c86986..eee9d60 100644 --- a/libxsde/xsde/cxx/serializer/non-validating/ncname.cxx +++ b/libxsde/xsde/cxx/serializer/non-validating/ncname.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -16,8 +20,15 @@ namespace xsde ncname_simpl:: ~ncname_simpl () { - if (free_) - delete[] const_cast (value_); + if (free_ && value_) + { + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif + } } void ncname_simpl:: @@ -33,7 +44,12 @@ namespace xsde if (free_) { - delete[] const_cast (value_); + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif value_ = 0; } } diff --git a/libxsde/xsde/cxx/serializer/non-validating/nmtoken.cxx b/libxsde/xsde/cxx/serializer/non-validating/nmtoken.cxx index a384c04..8f153ff 100644 --- a/libxsde/xsde/cxx/serializer/non-validating/nmtoken.cxx +++ b/libxsde/xsde/cxx/serializer/non-validating/nmtoken.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -16,8 +20,15 @@ namespace xsde nmtoken_simpl:: ~nmtoken_simpl () { - if (free_) - delete[] const_cast (value_); + if (free_ && value_) + { + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif + } } void nmtoken_simpl:: @@ -33,7 +44,12 @@ namespace xsde if (free_) { - delete[] const_cast (value_); + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif value_ = 0; } } diff --git a/libxsde/xsde/cxx/serializer/non-validating/nmtokens-stl.cxx b/libxsde/xsde/cxx/serializer/non-validating/nmtokens-stl.cxx index 6636b33..7cea1f1 100644 --- a/libxsde/xsde/cxx/serializer/non-validating/nmtokens-stl.cxx +++ b/libxsde/xsde/cxx/serializer/non-validating/nmtokens-stl.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -16,8 +20,16 @@ namespace xsde nmtokens_simpl:: ~nmtokens_simpl () { - if (free_) - delete const_cast (value_); + if (free_ && value_) + { + string_sequence* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete v; +#else + v->~string_sequence (); + cxx::free (v); +#endif + } } void nmtokens_simpl:: @@ -91,7 +103,13 @@ namespace xsde if (free_) { - delete const_cast (value_); + string_sequence* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete v; +#else + v->~string_sequence (); + cxx::free (v); +#endif value_ = 0; } } diff --git a/libxsde/xsde/cxx/serializer/non-validating/nmtokens.cxx b/libxsde/xsde/cxx/serializer/non-validating/nmtokens.cxx index ad40fc4..57afd8d 100644 --- a/libxsde/xsde/cxx/serializer/non-validating/nmtokens.cxx +++ b/libxsde/xsde/cxx/serializer/non-validating/nmtokens.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -16,8 +20,16 @@ namespace xsde nmtokens_simpl:: ~nmtokens_simpl () { - if (free_) - delete const_cast (value_); + if (free_ && value_) + { + string_sequence* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete v; +#else + v->~string_sequence (); + cxx::free (v); +#endif + } } void nmtokens_simpl:: @@ -91,7 +103,13 @@ namespace xsde if (free_) { - delete const_cast (value_); + string_sequence* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete v; +#else + v->~string_sequence (); + cxx::free (v); +#endif value_ = 0; } } @@ -106,4 +124,3 @@ namespace xsde } } } - diff --git a/libxsde/xsde/cxx/serializer/non-validating/normalized-string-stl.cxx b/libxsde/xsde/cxx/serializer/non-validating/normalized-string-stl.cxx index 5810de3..b5209c3 100644 --- a/libxsde/xsde/cxx/serializer/non-validating/normalized-string-stl.cxx +++ b/libxsde/xsde/cxx/serializer/non-validating/normalized-string-stl.cxx @@ -33,4 +33,3 @@ namespace xsde } } } - diff --git a/libxsde/xsde/cxx/serializer/non-validating/normalized-string.cxx b/libxsde/xsde/cxx/serializer/non-validating/normalized-string.cxx index b1bbf29..202ac76 100644 --- a/libxsde/xsde/cxx/serializer/non-validating/normalized-string.cxx +++ b/libxsde/xsde/cxx/serializer/non-validating/normalized-string.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -16,8 +20,15 @@ namespace xsde normalized_string_simpl:: ~normalized_string_simpl () { - if (free_) - delete[] const_cast (value_); + if (free_ && value_) + { + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif + } } void normalized_string_simpl:: @@ -33,7 +44,12 @@ namespace xsde if (free_) { - delete[] const_cast (value_); + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif value_ = 0; } } @@ -41,4 +57,3 @@ namespace xsde } } } - diff --git a/libxsde/xsde/cxx/serializer/non-validating/qname.cxx b/libxsde/xsde/cxx/serializer/non-validating/qname.cxx index 19c7daa..ec267ef 100644 --- a/libxsde/xsde/cxx/serializer/non-validating/qname.cxx +++ b/libxsde/xsde/cxx/serializer/non-validating/qname.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -16,8 +20,16 @@ namespace xsde qname_simpl:: ~qname_simpl () { - if (free_) - delete const_cast (value_); + if (free_ && value_) + { + qname* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete v; +#else + v->~qname (); + cxx::free (v); +#endif + } } void qname_simpl:: @@ -52,7 +64,13 @@ namespace xsde if (free_) { - delete const_cast (value_); + qname* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete v; +#else + v->~qname (); + cxx::free (v); +#endif value_ = 0; } } diff --git a/libxsde/xsde/cxx/serializer/non-validating/string.cxx b/libxsde/xsde/cxx/serializer/non-validating/string.cxx index 7b1e546..1c6c50f 100644 --- a/libxsde/xsde/cxx/serializer/non-validating/string.cxx +++ b/libxsde/xsde/cxx/serializer/non-validating/string.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -16,8 +20,15 @@ namespace xsde string_simpl:: ~string_simpl () { - if (free_) - delete[] const_cast (value_); + if (free_ && value_) + { + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif + } } void string_simpl:: @@ -33,7 +44,12 @@ namespace xsde if (free_) { - delete[] const_cast (value_); + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif value_ = 0; } } diff --git a/libxsde/xsde/cxx/serializer/non-validating/token.cxx b/libxsde/xsde/cxx/serializer/non-validating/token.cxx index 5ff0739..2af141c 100644 --- a/libxsde/xsde/cxx/serializer/non-validating/token.cxx +++ b/libxsde/xsde/cxx/serializer/non-validating/token.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -16,8 +20,15 @@ namespace xsde token_simpl:: ~token_simpl () { - if (free_) - delete[] const_cast (value_); + if (free_ && value_) + { + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif + } } void token_simpl:: @@ -33,7 +44,12 @@ namespace xsde if (free_) { - delete[] const_cast (value_); + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif value_ = 0; } } diff --git a/libxsde/xsde/cxx/serializer/non-validating/uri.cxx b/libxsde/xsde/cxx/serializer/non-validating/uri.cxx index 43bafbd..5640302 100644 --- a/libxsde/xsde/cxx/serializer/non-validating/uri.cxx +++ b/libxsde/xsde/cxx/serializer/non-validating/uri.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -16,8 +20,15 @@ namespace xsde uri_simpl:: ~uri_simpl () { - if (free_) - delete[] const_cast (value_); + if (free_ && value_) + { + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif + } } void uri_simpl:: @@ -33,7 +44,12 @@ namespace xsde if (free_) { - delete[] const_cast (value_); + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif value_ = 0; } } diff --git a/libxsde/xsde/cxx/serializer/substitution-map.cxx b/libxsde/xsde/cxx/serializer/substitution-map.cxx index 0dfc97f..28f01b5 100644 --- a/libxsde/xsde/cxx/serializer/substitution-map.cxx +++ b/libxsde/xsde/cxx/serializer/substitution-map.cxx @@ -12,6 +12,10 @@ # include // exit #endif +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + #include #include @@ -29,7 +33,14 @@ namespace xsde { for (const_iterator i (begin ()), e (end ()); i != e; ++i) { - delete *static_cast (const_cast (*i)); + hashmap* p = *static_cast (const_cast (*i)); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete p; +#else + if (p) + p->~hashmap (); + cxx::free (p); +#endif } } @@ -45,8 +56,23 @@ namespace xsde m = *static_cast (const_cast (p)); else { +#ifndef XSDE_CUSTOM_ALLOCATOR m = new hashmap (XSDE_SERIALIZER_SMAP_BUCKET_BUCKETS, sizeof (value)); +#else + m = static_cast (alloc (sizeof (hashmap))); + +#ifdef XSDE_EXCEPTIONS + alloc_guard mg (m); + new (m) hashmap (XSDE_SERIALIZER_SMAP_BUCKET_BUCKETS, + sizeof (value)); + mg.release (); +#else + if (m) + new (m) hashmap (XSDE_SERIALIZER_SMAP_BUCKET_BUCKETS, + sizeof (value)); +#endif +#endif #ifndef XSDE_EXCEPTIONS if (m == 0 || m->_error () != hashmap::error_none) @@ -166,7 +192,21 @@ namespace xsde { if (count == 0) { +#ifndef XSDE_CUSTOM_ALLOCATOR map = new substitution_map (XSDE_SERIALIZER_SMAP_BUCKETS); +#else + map = static_cast ( + alloc (sizeof (substitution_map))); + +#ifdef XSDE_EXCEPTIONS + alloc_guard mg (map); + new (map) substitution_map (XSDE_SERIALIZER_SMAP_BUCKETS); + mg.release (); +#else + if (map) + new (map) substitution_map (XSDE_SERIALIZER_SMAP_BUCKETS); +#endif +#endif #ifndef XSDE_EXCEPTIONS if (map == 0 || map->_error () != substitution_map::error_none) @@ -189,7 +229,14 @@ namespace xsde ~substitution_map_init () { if (--count == 0) + { +#ifndef XSDE_CUSTOM_ALLOCATOR delete map; +#else + map->~substitution_map (); + cxx::free (map); +#endif + } } // substitution_map_entry diff --git a/libxsde/xsde/cxx/serializer/validating/base64-binary.cxx b/libxsde/xsde/cxx/serializer/validating/base64-binary.cxx index e192be7..04b3ef0 100644 --- a/libxsde/xsde/cxx/serializer/validating/base64-binary.cxx +++ b/libxsde/xsde/cxx/serializer/validating/base64-binary.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -16,8 +20,16 @@ namespace xsde base64_binary_simpl:: ~base64_binary_simpl () { - if (free_) - delete const_cast (value_); + if (free_ && value_) + { + buffer* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete v; +#else + v->~buffer (); + cxx::free (v); +#endif + } } void base64_binary_simpl:: @@ -156,7 +168,13 @@ namespace xsde if (free_) { - delete const_cast (value_); + buffer* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete v; +#else + v->~buffer (); + cxx::free (v); +#endif value_ = 0; } } diff --git a/libxsde/xsde/cxx/serializer/validating/hex-binary.cxx b/libxsde/xsde/cxx/serializer/validating/hex-binary.cxx index 5c3a8d5..712bbcb 100644 --- a/libxsde/xsde/cxx/serializer/validating/hex-binary.cxx +++ b/libxsde/xsde/cxx/serializer/validating/hex-binary.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -16,8 +20,16 @@ namespace xsde hex_binary_simpl:: ~hex_binary_simpl () { - if (free_) - delete const_cast (value_); + if (free_ && value_) + { + buffer* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete v; +#else + v->~buffer (); + cxx::free (v); +#endif + } } void hex_binary_simpl:: @@ -60,7 +72,13 @@ namespace xsde if (free_) { - delete const_cast (value_); + buffer* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete v; +#else + v->~buffer (); + cxx::free (v); +#endif value_ = 0; } } diff --git a/libxsde/xsde/cxx/serializer/validating/id.cxx b/libxsde/xsde/cxx/serializer/validating/id.cxx index 55e91ef..b9baf40 100644 --- a/libxsde/xsde/cxx/serializer/validating/id.cxx +++ b/libxsde/xsde/cxx/serializer/validating/id.cxx @@ -10,6 +10,10 @@ #include #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -21,8 +25,15 @@ namespace xsde id_simpl:: ~id_simpl () { - if (free_) - delete[] const_cast (value_); + if (free_ && value_) + { + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif + } } void id_simpl:: @@ -49,7 +60,12 @@ namespace xsde if (free_) { - delete[] const_cast (value_); + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif value_ = 0; } } diff --git a/libxsde/xsde/cxx/serializer/validating/idref.cxx b/libxsde/xsde/cxx/serializer/validating/idref.cxx index 93e4228..f4f3014 100644 --- a/libxsde/xsde/cxx/serializer/validating/idref.cxx +++ b/libxsde/xsde/cxx/serializer/validating/idref.cxx @@ -10,6 +10,10 @@ #include #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -21,8 +25,15 @@ namespace xsde idref_simpl:: ~idref_simpl () { - if (free_) - delete[] const_cast (value_); + if (free_ && value_) + { + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif + } } void idref_simpl:: @@ -49,7 +60,12 @@ namespace xsde if (free_) { - delete[] const_cast (value_); + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif value_ = 0; } } diff --git a/libxsde/xsde/cxx/serializer/validating/idrefs-stl.cxx b/libxsde/xsde/cxx/serializer/validating/idrefs-stl.cxx index df51d23..04f225a 100644 --- a/libxsde/xsde/cxx/serializer/validating/idrefs-stl.cxx +++ b/libxsde/xsde/cxx/serializer/validating/idrefs-stl.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -16,8 +20,16 @@ namespace xsde idrefs_simpl:: ~idrefs_simpl () { - if (free_) - delete const_cast (value_); + if (free_ && value_) + { + string_sequence* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete v; +#else + v->~string_sequence (); + cxx::free (v); +#endif + } } void idrefs_simpl:: @@ -92,7 +104,13 @@ namespace xsde if (free_) { - delete const_cast (value_); + string_sequence* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete v; +#else + v->~string_sequence (); + cxx::free (v); +#endif value_ = 0; } } diff --git a/libxsde/xsde/cxx/serializer/validating/idrefs.cxx b/libxsde/xsde/cxx/serializer/validating/idrefs.cxx index da2ac9b..4b5d7d2 100644 --- a/libxsde/xsde/cxx/serializer/validating/idrefs.cxx +++ b/libxsde/xsde/cxx/serializer/validating/idrefs.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -16,8 +20,16 @@ namespace xsde idrefs_simpl:: ~idrefs_simpl () { - if (free_) - delete const_cast (value_); + if (free_ && value_) + { + string_sequence* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete v; +#else + v->~string_sequence (); + cxx::free (v); +#endif + } } void idrefs_simpl:: @@ -92,7 +104,13 @@ namespace xsde if (free_) { - delete const_cast (value_); + string_sequence* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete v; +#else + v->~string_sequence (); + cxx::free (v); +#endif value_ = 0; } } @@ -107,4 +125,3 @@ namespace xsde } } } - diff --git a/libxsde/xsde/cxx/serializer/validating/inheritance-map.cxx b/libxsde/xsde/cxx/serializer/validating/inheritance-map.cxx index 35e2dc5..b320ee7 100644 --- a/libxsde/xsde/cxx/serializer/validating/inheritance-map.cxx +++ b/libxsde/xsde/cxx/serializer/validating/inheritance-map.cxx @@ -12,6 +12,10 @@ # include // exit #endif +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + #include #include @@ -50,7 +54,21 @@ namespace xsde { if (count == 0) { +#ifndef XSDE_CUSTOM_ALLOCATOR map = new inheritance_map (XSDE_SERIALIZER_IMAP_BUCKETS); +#else + map = static_cast ( + alloc (sizeof (inheritance_map))); + +#ifdef XSDE_EXCEPTIONS + alloc_guard mg (map); + new (map) inheritance_map (XSDE_SERIALIZER_IMAP_BUCKETS); + mg.release (); +#else + if (map) + new (map) inheritance_map (XSDE_SERIALIZER_IMAP_BUCKETS); +#endif +#endif #ifndef XSDE_EXCEPTIONS if (map == 0 || map->_error () != inheritance_map::error_none) @@ -73,7 +91,14 @@ namespace xsde ~inheritance_map_init () { if (--count == 0) + { +#ifndef XSDE_CUSTOM_ALLOCATOR delete map; +#else + map->~inheritance_map (); + cxx::free (map); +#endif + } } // inheritance_map_entry diff --git a/libxsde/xsde/cxx/serializer/validating/language.cxx b/libxsde/xsde/cxx/serializer/validating/language.cxx index 662c512..08be3bf 100644 --- a/libxsde/xsde/cxx/serializer/validating/language.cxx +++ b/libxsde/xsde/cxx/serializer/validating/language.cxx @@ -6,6 +6,10 @@ #include #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -17,8 +21,15 @@ namespace xsde language_simpl:: ~language_simpl () { - if (free_) - delete[] const_cast (value_); + if (free_ && value_) + { + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif + } } void language_simpl:: @@ -78,7 +89,12 @@ namespace xsde if (free_) { - delete[] const_cast (value_); + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif value_ = 0; } } diff --git a/libxsde/xsde/cxx/serializer/validating/name.cxx b/libxsde/xsde/cxx/serializer/validating/name.cxx index c1fec6e..4c974c0 100644 --- a/libxsde/xsde/cxx/serializer/validating/name.cxx +++ b/libxsde/xsde/cxx/serializer/validating/name.cxx @@ -8,6 +8,10 @@ #include #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -19,8 +23,15 @@ namespace xsde name_simpl:: ~name_simpl () { - if (free_) - delete[] const_cast (value_); + if (free_ && value_) + { + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif + } } void name_simpl:: @@ -67,7 +78,12 @@ namespace xsde if (free_) { - delete[] const_cast (value_); + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif value_ = 0; } } diff --git a/libxsde/xsde/cxx/serializer/validating/ncname.cxx b/libxsde/xsde/cxx/serializer/validating/ncname.cxx index ee6079b..86b9ecb 100644 --- a/libxsde/xsde/cxx/serializer/validating/ncname.cxx +++ b/libxsde/xsde/cxx/serializer/validating/ncname.cxx @@ -10,6 +10,10 @@ #include #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -21,8 +25,15 @@ namespace xsde ncname_simpl:: ~ncname_simpl () { - if (free_) - delete[] const_cast (value_); + if (free_ && value_) + { + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif + } } void ncname_simpl:: @@ -49,7 +60,12 @@ namespace xsde if (free_) { - delete[] const_cast (value_); + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif value_ = 0; } } diff --git a/libxsde/xsde/cxx/serializer/validating/nmtoken.cxx b/libxsde/xsde/cxx/serializer/validating/nmtoken.cxx index a230b57..c2f4a12 100644 --- a/libxsde/xsde/cxx/serializer/validating/nmtoken.cxx +++ b/libxsde/xsde/cxx/serializer/validating/nmtoken.cxx @@ -8,6 +8,10 @@ #include #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -19,8 +23,15 @@ namespace xsde nmtoken_simpl:: ~nmtoken_simpl () { - if (free_) - delete[] const_cast (value_); + if (free_ && value_) + { + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif + } } void nmtoken_simpl:: @@ -58,7 +69,12 @@ namespace xsde if (free_) { - delete[] const_cast (value_); + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif value_ = 0; } } diff --git a/libxsde/xsde/cxx/serializer/validating/nmtokens-stl.cxx b/libxsde/xsde/cxx/serializer/validating/nmtokens-stl.cxx index 9633fbe..b72ae0a 100644 --- a/libxsde/xsde/cxx/serializer/validating/nmtokens-stl.cxx +++ b/libxsde/xsde/cxx/serializer/validating/nmtokens-stl.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -16,8 +20,16 @@ namespace xsde nmtokens_simpl:: ~nmtokens_simpl () { - if (free_) - delete const_cast (value_); + if (free_ && value_) + { + string_sequence* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete v; +#else + v->~string_sequence (); + cxx::free (v); +#endif + } } void nmtokens_simpl:: @@ -92,7 +104,13 @@ namespace xsde if (free_) { - delete const_cast (value_); + string_sequence* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete v; +#else + v->~string_sequence (); + cxx::free (v); +#endif value_ = 0; } } diff --git a/libxsde/xsde/cxx/serializer/validating/nmtokens.cxx b/libxsde/xsde/cxx/serializer/validating/nmtokens.cxx index 9c93ef5..bfc52be 100644 --- a/libxsde/xsde/cxx/serializer/validating/nmtokens.cxx +++ b/libxsde/xsde/cxx/serializer/validating/nmtokens.cxx @@ -5,6 +5,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -16,8 +20,16 @@ namespace xsde nmtokens_simpl:: ~nmtokens_simpl () { - if (free_) - delete const_cast (value_); + if (free_ && value_) + { + string_sequence* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete v; +#else + v->~string_sequence (); + cxx::free (v); +#endif + } } void nmtokens_simpl:: @@ -92,7 +104,13 @@ namespace xsde if (free_) { - delete const_cast (value_); + string_sequence* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete v; +#else + v->~string_sequence (); + cxx::free (v); +#endif value_ = 0; } } @@ -107,4 +125,3 @@ namespace xsde } } } - diff --git a/libxsde/xsde/cxx/serializer/validating/normalized-string.cxx b/libxsde/xsde/cxx/serializer/validating/normalized-string.cxx index 89bb32c..8d807a4 100644 --- a/libxsde/xsde/cxx/serializer/validating/normalized-string.cxx +++ b/libxsde/xsde/cxx/serializer/validating/normalized-string.cxx @@ -6,6 +6,10 @@ #include #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -17,8 +21,15 @@ namespace xsde normalized_string_simpl:: ~normalized_string_simpl () { - if (free_) - delete[] const_cast (value_); + if (free_ && value_) + { + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif + } } void normalized_string_simpl:: @@ -51,7 +62,12 @@ namespace xsde if (free_) { - delete[] const_cast (value_); + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif value_ = 0; } } diff --git a/libxsde/xsde/cxx/serializer/validating/qname.cxx b/libxsde/xsde/cxx/serializer/validating/qname.cxx index a51685e..cca29d6 100644 --- a/libxsde/xsde/cxx/serializer/validating/qname.cxx +++ b/libxsde/xsde/cxx/serializer/validating/qname.cxx @@ -9,6 +9,10 @@ #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -20,8 +24,16 @@ namespace xsde qname_simpl:: ~qname_simpl () { - if (free_) - delete const_cast (value_); + if (free_ && value_) + { + qname* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete v; +#else + v->~qname (); + cxx::free (v); +#endif + } } void qname_simpl:: @@ -69,7 +81,13 @@ namespace xsde if (free_) { - delete const_cast (value_); + qname* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete v; +#else + v->~qname (); + cxx::free (v); +#endif value_ = 0; } } diff --git a/libxsde/xsde/cxx/serializer/validating/string.cxx b/libxsde/xsde/cxx/serializer/validating/string.cxx index a8d287e..a8f6dfa 100644 --- a/libxsde/xsde/cxx/serializer/validating/string.cxx +++ b/libxsde/xsde/cxx/serializer/validating/string.cxx @@ -6,6 +6,10 @@ #include #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -17,8 +21,15 @@ namespace xsde string_simpl:: ~string_simpl () { - if (free_) - delete[] const_cast (value_); + if (free_ && value_) + { + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif + } } void string_simpl:: @@ -38,7 +49,12 @@ namespace xsde if (free_) { - delete[] const_cast (value_); + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif value_ = 0; } } diff --git a/libxsde/xsde/cxx/serializer/validating/token.cxx b/libxsde/xsde/cxx/serializer/validating/token.cxx index 30e98f8..d38ef33 100644 --- a/libxsde/xsde/cxx/serializer/validating/token.cxx +++ b/libxsde/xsde/cxx/serializer/validating/token.cxx @@ -6,6 +6,10 @@ #include #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -17,8 +21,15 @@ namespace xsde token_simpl:: ~token_simpl () { - if (free_) - delete[] const_cast (value_); + if (free_ && value_) + { + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif + } } void token_simpl:: @@ -63,7 +74,12 @@ namespace xsde if (free_) { - delete[] const_cast (value_); + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif value_ = 0; } } diff --git a/libxsde/xsde/cxx/serializer/validating/uri.cxx b/libxsde/xsde/cxx/serializer/validating/uri.cxx index a1b7a86..3cfdc26 100644 --- a/libxsde/xsde/cxx/serializer/validating/uri.cxx +++ b/libxsde/xsde/cxx/serializer/validating/uri.cxx @@ -6,6 +6,10 @@ #include #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -17,8 +21,15 @@ namespace xsde uri_simpl:: ~uri_simpl () { - if (free_) - delete[] const_cast (value_); + if (free_ && value_) + { + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif + } } void uri_simpl:: @@ -42,7 +53,12 @@ namespace xsde if (free_) { - delete[] const_cast (value_); + char* v = const_cast (value_); +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] v; +#else + cxx::free (v); +#endif value_ = 0; } } diff --git a/libxsde/xsde/cxx/stack.cxx b/libxsde/xsde/cxx/stack.cxx index 936a732..9ed2270 100644 --- a/libxsde/xsde/cxx/stack.cxx +++ b/libxsde/xsde/cxx/stack.cxx @@ -19,7 +19,12 @@ namespace xsde grow () { size_t c = capacity_ ? capacity_ * 2 : 8; - char* d = new char[c * el_size_]; + +#ifndef XSDE_CUSTOM_ALLOCATOR + char* d = static_cast (operator new (c * el_size_)); +#else + char* d = static_cast (alloc (c * el_size_)); +#endif #ifndef XSDE_EXCEPTIONS if (d == 0) @@ -29,7 +34,11 @@ namespace xsde if (size_ > 1) memcpy (d, data_, (size_ - 1) * el_size_); +#ifndef XSDE_CUSTOM_ALLOCATOR delete[] data_; +#else + cxx::free (data_); +#endif data_ = d; capacity_ = c; diff --git a/libxsde/xsde/cxx/stack.ixx b/libxsde/xsde/cxx/stack.ixx index 05c60ac..8b69407 100644 --- a/libxsde/xsde/cxx/stack.ixx +++ b/libxsde/xsde/cxx/stack.ixx @@ -3,6 +3,12 @@ // copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#else +# include // operator new/delete +#endif + namespace xsde { namespace cxx @@ -10,7 +16,12 @@ namespace xsde inline stack:: ~stack () { - delete[] data_; + if (data_) +#ifndef XSDE_CUSTOM_ALLOCATOR + operator delete (data_); +#else + cxx::free (data_); +#endif } inline stack:: diff --git a/libxsde/xsde/cxx/strdupx.cxx b/libxsde/xsde/cxx/strdupx.cxx index 840bf3f..c9b68c4 100644 --- a/libxsde/xsde/cxx/strdupx.cxx +++ b/libxsde/xsde/cxx/strdupx.cxx @@ -8,6 +8,10 @@ #include #include +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -16,7 +20,12 @@ namespace xsde strdupx (const char* s) { size_t n = strlen (s); + +#ifndef XSDE_CUSTOM_ALLOCATOR char* r = new char[n + 1]; +#else + char* r = static_cast (alloc (n + 1)); +#endif #ifndef XSDE_EXCEPTIONS if (r) @@ -29,7 +38,11 @@ namespace xsde char* strndupx (const char* s, size_t n) { +#ifndef XSDE_CUSTOM_ALLOCATOR char* r = new char[n + 1]; +#else + char* r = static_cast (alloc (n + 1)); +#endif #ifndef XSDE_EXCEPTIONS if (r) diff --git a/libxsde/xsde/cxx/strdupx.hxx b/libxsde/xsde/cxx/strdupx.hxx index 190d519..eef6922 100644 --- a/libxsde/xsde/cxx/strdupx.hxx +++ b/libxsde/xsde/cxx/strdupx.hxx @@ -13,8 +13,9 @@ namespace xsde namespace cxx { // C++ versions of strdup and strndup. They allocate the string - // using new char[]. In the no-exceptions case return 0 if - // allocation fails. + // using new char[] (or custom allocator, if enabled). When + // exceptions are disabled these functions return 0 if allocation + // fails. // char* strdupx (const char*); diff --git a/libxsde/xsde/cxx/string-sequence.cxx b/libxsde/xsde/cxx/string-sequence.cxx index d10ec34..5387e79 100644 --- a/libxsde/xsde/cxx/string-sequence.cxx +++ b/libxsde/xsde/cxx/string-sequence.cxx @@ -3,8 +3,9 @@ // copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file -#include // memcpy, strlen, strcmp +#include // strcmp +#include #include namespace xsde @@ -15,7 +16,11 @@ namespace xsde clear () { for (size_t i = 0; i < size_; ++i) +#ifndef XSDE_CUSTOM_ALLOCATOR delete[] static_cast (data_)[i]; +#else + cxx::free (static_cast (data_)[i]); +#endif size_ = 0; } @@ -27,11 +32,7 @@ namespace xsde if (capacity_ < size_ + 1) grow_ (0, sizeof (char*), 0); - size_t n = strlen (cs) + 1; - char* s = new char[n]; - memcpy (s, cs, n); - - static_cast (data_)[size_++] = s; + static_cast (data_)[size_++] = strdupx (cs); } #else string_sequence::error string_sequence:: @@ -44,14 +45,10 @@ namespace xsde if (r == error_none) { - size_t n = strlen (cs) + 1; - char* s = new char[n]; + char* s = strdupx (cs); if (s != 0) - { - memcpy (s, cs, n); static_cast (data_)[size_++] = s; - } else r = error_no_memory; } diff --git a/libxsde/xsde/cxx/string-sequence.ixx b/libxsde/xsde/cxx/string-sequence.ixx index 4c7f42d..b902bd7 100644 --- a/libxsde/xsde/cxx/string-sequence.ixx +++ b/libxsde/xsde/cxx/string-sequence.ixx @@ -3,6 +3,10 @@ // copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -90,14 +94,22 @@ namespace xsde inline void string_sequence:: pop_back () { +#ifndef XSDE_CUSTOM_ALLOCATOR delete[] static_cast (data_)[size_ - 1]; +#else + cxx::free (static_cast (data_)[size_ - 1]); +#endif --size_; } inline string_sequence::iterator string_sequence:: erase (iterator i) { +#ifndef XSDE_CUSTOM_ALLOCATOR delete[] *i; +#else + cxx::free (*i); +#endif if (i != static_cast (data_) + (size_ - 1)) erase_ (i, sizeof (char*), 0); @@ -112,7 +124,15 @@ namespace xsde { struct guard { - ~guard () { delete[] p_; } + ~guard () + { +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] p_; +#else + cxx::free (p_); +#endif + } + guard (char* p) : p_ (p) {} void @@ -164,7 +184,11 @@ namespace xsde if (r == error_none) static_cast (data_)[size_++] = x; else +#ifndef XSDE_CUSTOM_ALLOCATOR delete[] x; +#else + cxx::free (x); +#endif return r; } @@ -181,7 +205,11 @@ namespace xsde } else { +#ifndef XSDE_CUSTOM_ALLOCATOR delete[] x; +#else + cxx::free (x); +#endif return error_no_memory; } } @@ -199,7 +227,11 @@ namespace xsde } else { +#ifndef XSDE_CUSTOM_ALLOCATOR delete[] x; +#else + cxx::free (x); +#endif return error_no_memory; } } @@ -225,7 +257,12 @@ namespace xsde inline void string_sequence:: attach (iterator p, char* x) { +#ifndef XSDE_CUSTOM_ALLOCATOR delete[] *p; +#else + cxx::free (*p); +#endif + *p = x; } diff --git a/libxsde/xsde/cxx/string.cxx b/libxsde/xsde/cxx/string.cxx index 5284220..02c8d04 100644 --- a/libxsde/xsde/cxx/string.cxx +++ b/libxsde/xsde/cxx/string.cxx @@ -56,7 +56,11 @@ namespace xsde else new_cap += (new_cap & 1) ? 1 : 0; // Make even. +#ifndef XSDE_CUSTOM_ALLOCATOR char* p = new char[new_cap]; +#else + char* p = static_cast (alloc (new_cap)); +#endif if (p == 0) return error_no_memory; @@ -64,7 +68,11 @@ namespace xsde if (copy && size_ != 0) memcpy (p, data_, size_ + 1); +#ifndef XSDE_CUSTOM_ALLOCATOR delete[] data_; +#else + cxx::free (data_); +#endif data_ = p; capacity_ = new_cap; diff --git a/libxsde/xsde/cxx/string.ixx b/libxsde/xsde/cxx/string.ixx index ce479bb..f8f8378 100644 --- a/libxsde/xsde/cxx/string.ixx +++ b/libxsde/xsde/cxx/string.ixx @@ -5,6 +5,12 @@ #include +#include + +#ifdef XSDE_CUSTOM_ALLOCATOR +# include +#endif + namespace xsde { namespace cxx @@ -12,7 +18,11 @@ namespace xsde inline string:: ~string () { +#ifndef XSDE_CUSTOM_ALLOCATOR delete[] data_; +#else + cxx::free (data_); +#endif } inline string:: @@ -40,7 +50,11 @@ namespace xsde inline void string:: attach (char* s, size_t n) { +#ifndef XSDE_CUSTOM_ALLOCATOR delete[] data_; +#else + cxx::free (data_); +#endif data_ = s; size_ = n; diff --git a/libxsde/xsde/makefile b/libxsde/xsde/makefile index f313347..2ec1c41 100644 --- a/libxsde/xsde/makefile +++ b/libxsde/xsde/makefile @@ -8,12 +8,24 @@ include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make c_tun := c/expat/xmlparse.c c/expat/xmlrole.c c/expat/xmltok.c c_tun += c/genx/genx.c c/genx/char-props.c +ifeq ($(xsde_custom_allocator),y) +ifeq ($(xsde_default_allocator),y) +c_tun += allocator.c +endif +endif + cxx_tun := \ cxx/string.cxx \ cxx/string-search.cxx \ cxx/ro-string.cxx \ cxx/stack.cxx +ifeq ($(xsde_custom_allocator),y) +ifeq ($(xsde_exceptions),y) +cxx_tun += cxx/allocator.cxx +endif +endif + ifeq ($(xsde_encoding),iso8859-1) cxx_tun += cxx/iso8859-1.cxx endif @@ -592,6 +604,16 @@ ifeq ($(xsde_reuse_style),none) else @echo '#undef XSDE_REUSE_STYLE_NONE' >>$@ endif +ifeq ($(xsde_custom_allocator),y) + @echo '#define XSDE_CUSTOM_ALLOCATOR' >>$@ +else + @echo '#undef XSDE_CUSTOM_ALLOCATOR' >>$@ +endif +ifeq ($(xsde_default_allocator),y) + @echo '#define XSDE_DEFAULT_ALLOCATOR' >>$@ +else + @echo '#undef XSDE_DEFAULT_ALLOCATOR' >>$@ +endif ifeq ($(xsde_polymorphic),y) @echo '#define XSDE_POLYMORPHIC' >>$@ @echo '#define XSDE_PARSER_SMAP_BUCKETS $(xsde_parser_smap_buckets)UL' >>$@ @@ -618,6 +640,8 @@ $(out_base)/: $(xsde.l) # Dist. # $(dist): + $(call install-data,$(src_base)/allocator.h,$(dist_prefix)/libxsde/xsde/allocator.h) + $(call install-data,$(src_base)/allocator.c,$(dist_prefix)/libxsde/xsde/allocator.c) $(call install-dir,$(src_base)/c,$(dist_prefix)/libxsde/xsde/c,\( -name '*.h' -o -name '*.c' -o -name COPYING \)) $(call install-dir,$(src_base)/cxx,$(dist_prefix)/libxsde/xsde/cxx,-name '*.?xx') -- cgit v1.1