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/serializer/validating/inheritance-map.cxx | |
parent | 161beba6cdb0d91b15ad19fa8b3e51d986203915 (diff) |
Add support for custom allocators
New example: examples/cxx/hybrid/allocator.
Diffstat (limited to 'libxsde/xsde/cxx/serializer/validating/inheritance-map.cxx')
-rw-r--r-- | libxsde/xsde/cxx/serializer/validating/inheritance-map.cxx | 25 |
1 files changed, 25 insertions, 0 deletions
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 <stdlib.h> // exit #endif +#ifdef XSDE_CUSTOM_ALLOCATOR +# include <xsde/cxx/allocator.hxx> +#endif + #include <xsde/cxx/serializer/validating/inheritance-map.hxx> #include <xsde/cxx/serializer/validating/inheritance-map-load.hxx> @@ -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<inheritance_map*> ( + 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 |