diff options
Diffstat (limited to 'libxsde/xsde/cxx/hybrid/cdr')
-rw-r--r-- | libxsde/xsde/cxx/hybrid/cdr/istream.cxx | 13 | ||||
-rw-r--r-- | libxsde/xsde/cxx/hybrid/cdr/istream.txx | 25 |
2 files changed, 37 insertions, 1 deletions
diff --git a/libxsde/xsde/cxx/hybrid/cdr/istream.cxx b/libxsde/xsde/cxx/hybrid/cdr/istream.cxx index 684df2d..06e26e6 100644 --- a/libxsde/xsde/cxx/hybrid/cdr/istream.cxx +++ b/libxsde/xsde/cxx/hybrid/cdr/istream.cxx @@ -17,7 +17,14 @@ namespace xsde struct str_guard { str_guard (char* s) : s_ (s) {} - ~str_guard () {delete[] s_;} + ~str_guard () + { +#ifndef XSDE_CUSTOM_ALLOCATOR + delete[] s_; +#else + cxx::free (s_); +#endif + } private: char* s_; @@ -70,7 +77,11 @@ namespace xsde return false; x = v; +#ifndef XSDE_CUSTOM_ALLOCATOR delete[] v; +#else + cxx::free (v); +#endif return true; } #else diff --git a/libxsde/xsde/cxx/hybrid/cdr/istream.txx b/libxsde/xsde/cxx/hybrid/cdr/istream.txx index 58cd98b..f1d8d6c 100644 --- a/libxsde/xsde/cxx/hybrid/cdr/istream.txx +++ b/libxsde/xsde/cxx/hybrid/cdr/istream.txx @@ -3,6 +3,10 @@ // copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file +#ifdef XSDE_CUSTOM_ALLOCATOR +# include <xsde/cxx/allocator.hxx> +#endif + namespace xsde { namespace cxx @@ -73,7 +77,14 @@ namespace xsde while (n--) { +#ifndef XSDE_CUSTOM_ALLOCATOR T* p = new T; +#else + T* p = static_cast<T*> (alloc (sizeof (T))); + alloc_guard pg (p); + new (p) T; + pg.release (); +#endif typename var_sequence<T>::guard g (p); s >> *p; g.release (); @@ -159,14 +170,28 @@ namespace xsde while (n--) { +#ifndef XSDE_CUSTOM_ALLOCATOR T* p = new T; if (p == 0) return false; +#else + void* v = alloc (sizeof (T)); + + if (v == 0) + return false; + + T* p = new (v) T; // c-tor cannot fail +#endif if (!(s >> *p)) { +#ifndef XSDE_CUSTOM_ALLOCATOR delete p; +#else + p->~T (); + cxx::free (p); +#endif return false; } |