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/non-validating/nmtokens-stl.cxx | |
parent | 161beba6cdb0d91b15ad19fa8b3e51d986203915 (diff) |
Add support for custom allocators
New example: examples/cxx/hybrid/allocator.
Diffstat (limited to 'libxsde/xsde/cxx/parser/non-validating/nmtokens-stl.cxx')
-rw-r--r-- | libxsde/xsde/cxx/parser/non-validating/nmtokens-stl.cxx | 34 |
1 files changed, 32 insertions, 2 deletions
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) |