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