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. --- .../cxx/serializer/non-validating/hex-binary.cxx | 24 +++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'libxsde/xsde/cxx/serializer/non-validating/hex-binary.cxx') 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; } } -- cgit v1.1