diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2010-05-11 12:20:11 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2010-05-11 12:20:11 +0200 |
commit | 2e501c68a8641a2b3c430b55f13491a9c1c5d0f5 (patch) | |
tree | 49c2748443fe3c1f01108756b647440e0647a11b /libxsde/xsde/cxx/parser | |
parent | 161beba6cdb0d91b15ad19fa8b3e51d986203915 (diff) |
Add support for custom allocators
New example: examples/cxx/hybrid/allocator.
Diffstat (limited to 'libxsde/xsde/cxx/parser')
21 files changed, 513 insertions, 33 deletions
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 <fstream> #endif +#ifdef XSDE_CUSTOM_ALLOCATOR +# include <xsde/cxx/allocator.hxx> +#endif + #ifdef XSDE_ENCODING_ISO8859_1 # include <xsde/cxx/iso8859-1.hxx> #endif @@ -1291,7 +1295,11 @@ namespace xsde buf = data_buf_; else { +#ifndef XSDE_CUSTOM_ALLOCATOR buf = new char[iso_n]; +#else + buf = static_cast<char*> (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<char*> (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<char*> (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 <xsde/cxx/config.hxx> +#ifdef XSDE_CUSTOM_ALLOCATOR +# include <xsde/cxx/allocator.hxx> +#endif + #include <xsde/cxx/parser/non-validating/base64-binary.hxx> 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<buffer*> (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 <xsde/cxx/config.hxx> +#ifdef XSDE_CUSTOM_ALLOCATOR +# include <xsde/cxx/allocator.hxx> +#endif + #include <xsde/cxx/parser/non-validating/hex-binary.hxx> 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<buffer*> (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 <xsde/cxx/config.hxx> +#ifdef XSDE_CUSTOM_ALLOCATOR +# include <xsde/cxx/allocator.hxx> +#endif + #include <xsde/cxx/parser/non-validating/idrefs-stl.hxx> 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<string_sequence*> ( + 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 <xsde/cxx/config.hxx> +#ifdef XSDE_CUSTOM_ALLOCATOR +# include <xsde/cxx/allocator.hxx> +#endif + #include <xsde/cxx/parser/non-validating/idrefs.hxx> 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<string_sequence*> ( + 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 <xsde/cxx/config.hxx> +#ifdef XSDE_CUSTOM_ALLOCATOR +# include <xsde/cxx/allocator.hxx> +#endif + #include <xsde/cxx/parser/non-validating/nmtokens-stl.hxx> 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<string_sequence*> ( + 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 <xsde/cxx/config.hxx> +#ifdef XSDE_CUSTOM_ALLOCATOR +# include <xsde/cxx/allocator.hxx> +#endif + #include <xsde/cxx/parser/non-validating/nmtokens.hxx> 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<string_sequence*> ( + 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 <xsde/cxx/config.hxx> #include <xsde/cxx/string.hxx> +#ifdef XSDE_CUSTOM_ALLOCATOR +# include <xsde/cxx/allocator.hxx> +#endif + #include <xsde/cxx/parser/non-validating/qname.hxx> 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<qname*> (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 <stdlib.h> // exit #endif +#ifdef XSDE_CUSTOM_ALLOCATOR +# include <xsde/cxx/allocator.hxx> +#endif + #include <xsde/cxx/parser/substitution-map.hxx> #include <xsde/cxx/parser/substitution-map-load.hxx> @@ -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<substitution_map*> ( + 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 <xsde/cxx/config.hxx> +#ifdef XSDE_CUSTOM_ALLOCATOR +# include <xsde/cxx/allocator.hxx> +#endif + #include <xsde/cxx/parser/validating/base64-binary.hxx> 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<buffer*> (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 <xsde/cxx/config.hxx> +#ifdef XSDE_CUSTOM_ALLOCATOR +# include <xsde/cxx/allocator.hxx> +#endif + #include <xsde/cxx/parser/validating/hex-binary.hxx> 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<buffer*> (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 <xsde/cxx/config.hxx> +#ifdef XSDE_CUSTOM_ALLOCATOR +# include <xsde/cxx/allocator.hxx> +#endif + #include <xsde/cxx/parser/validating/idrefs-stl.hxx> 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<string_sequence*> ( + 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 <xsde/cxx/config.hxx> +#ifdef XSDE_CUSTOM_ALLOCATOR +# include <xsde/cxx/allocator.hxx> +#endif + #include <xsde/cxx/parser/validating/idrefs.hxx> 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<string_sequence*> ( + 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 <stdlib.h> // exit #endif +#ifdef XSDE_CUSTOM_ALLOCATOR +# include <xsde/cxx/allocator.hxx> +#endif + #include <xsde/cxx/parser/validating/inheritance-map.hxx> #include <xsde/cxx/parser/validating/inheritance-map-load.hxx> @@ -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<inheritance_map*> ( + 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 <xsde/cxx/config.hxx> +#ifdef XSDE_CUSTOM_ALLOCATOR +# include <xsde/cxx/allocator.hxx> +#endif + #include <xsde/cxx/parser/validating/nmtokens-stl.hxx> 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<string_sequence*> ( + 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 <xsde/cxx/config.hxx> +#ifdef XSDE_CUSTOM_ALLOCATOR +# include <xsde/cxx/allocator.hxx> +#endif + #include <xsde/cxx/parser/validating/nmtokens.hxx> 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<string_sequence*> ( + 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 <xsde/cxx/config.hxx> +#ifdef XSDE_CUSTOM_ALLOCATOR +# include <xsde/cxx/allocator.hxx> +#endif + #include <xsde/cxx/xml/ncname.hxx> #include <xsde/cxx/parser/validating/qname.hxx> @@ -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<qname*> (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 |