aboutsummaryrefslogtreecommitdiff
path: root/xsde/cxx/hybrid/default-value.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-05-11 12:20:11 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-05-11 12:20:11 +0200
commit2e501c68a8641a2b3c430b55f13491a9c1c5d0f5 (patch)
tree49c2748443fe3c1f01108756b647440e0647a11b /xsde/cxx/hybrid/default-value.cxx
parent161beba6cdb0d91b15ad19fa8b3e51d986203915 (diff)
Add support for custom allocators
New example: examples/cxx/hybrid/allocator.
Diffstat (limited to 'xsde/cxx/hybrid/default-value.cxx')
-rw-r--r--xsde/cxx/hybrid/default-value.cxx24
1 files changed, 23 insertions, 1 deletions
diff --git a/xsde/cxx/hybrid/default-value.cxx b/xsde/cxx/hybrid/default-value.cxx
index a255c92..58a5507 100644
--- a/xsde/cxx/hybrid/default-value.cxx
+++ b/xsde/cxx/hybrid/default-value.cxx
@@ -499,7 +499,29 @@ namespace CXX
member_ = "tmp.";
else
{
- os << "tmp = new " << fq_name (t) << ";";
+ String tn (fq_name (t));
+
+ if (!custom_alloc)
+ os << "tmp = new " << tn << ";";
+ else
+ {
+ os << "tmp = static_cast< " << tn << "* > (" << endl
+ << "::xsde::cxx::alloc (sizeof (" << tn << ")));";
+
+ if (exceptions)
+ os << "::xsde::cxx::alloc_guard tmpg (tmp);";
+ else
+ os << endl
+ << "if (tmp)" << endl;
+
+ os << "new (tmp) " << fq_name (t) << ";";
+
+ if (exceptions)
+ os << "tmpg.release ();";
+ else
+ os << endl;
+
+ }
if (!exceptions)
{