aboutsummaryrefslogtreecommitdiff
path: root/libxsde/xsde/cxx/parser/validating
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 /libxsde/xsde/cxx/parser/validating
parent161beba6cdb0d91b15ad19fa8b3e51d986203915 (diff)
Add support for custom allocators
New example: examples/cxx/hybrid/allocator.
Diffstat (limited to 'libxsde/xsde/cxx/parser/validating')
-rw-r--r--libxsde/xsde/cxx/parser/validating/base64-binary.cxx33
-rw-r--r--libxsde/xsde/cxx/parser/validating/hex-binary.cxx33
-rw-r--r--libxsde/xsde/cxx/parser/validating/idrefs-stl.cxx34
-rw-r--r--libxsde/xsde/cxx/parser/validating/idrefs.cxx34
-rw-r--r--libxsde/xsde/cxx/parser/validating/inheritance-map.cxx25
-rw-r--r--libxsde/xsde/cxx/parser/validating/nmtokens-stl.cxx34
-rw-r--r--libxsde/xsde/cxx/parser/validating/nmtokens.cxx34
-rw-r--r--libxsde/xsde/cxx/parser/validating/qname.cxx33
-rw-r--r--libxsde/xsde/cxx/parser/validating/xml-schema-pskel.hxx3
9 files changed, 248 insertions, 15 deletions
diff --git a/libxsde/xsde/cxx/parser/validating/base64-binary.cxx b/libxsde/xsde/cxx/parser/validating/base64-binary.cxx
index 3aac6f3..f36df5a 100644
--- a/libxsde/xsde/cxx/parser/validating/base64-binary.cxx
+++ b/libxsde/xsde/cxx/parser/validating/base64-binary.cxx
@@ -5,6 +5,10 @@
#include <xsde/cxx/config.hxx>
+#ifdef XSDE_CUSTOM_ALLOCATOR
+# include <xsde/cxx/allocator.hxx>
+#endif
+
#include <xsde/cxx/parser/validating/base64-binary.hxx>
static unsigned char
@@ -37,8 +41,15 @@ namespace xsde
base64_binary_pimpl::
~base64_binary_pimpl ()
{
- if (!base_)
+ if (!base_ && buf_)
+ {
+#ifndef XSDE_CUSTOM_ALLOCATOR
delete buf_;
+#else
+ buf_->~buffer ();
+ cxx::free (buf_);
+#endif
+ }
}
void base64_binary_pimpl::
@@ -46,9 +57,14 @@ namespace xsde
{
base64_binary_pskel::_reset ();
- if (!base_)
+ if (!base_ && buf_)
{
+#ifndef XSDE_CUSTOM_ALLOCATOR
delete buf_;
+#else
+ buf_->~buffer ();
+ cxx::free (buf_);
+#endif
buf_ = 0;
}
}
@@ -70,7 +86,20 @@ namespace xsde
{
if (buf_ == 0)
{
+#ifndef XSDE_CUSTOM_ALLOCATOR
buf_ = new buffer ();
+#else
+ buf_ = static_cast<buffer*> (alloc (sizeof (buffer)));
+
+#ifdef XSDE_EXCEPTIONS
+ alloc_guard ag (buf_);
+ new (buf_) buffer ();
+ ag.release ();
+#else
+ if (buf_)
+ new (buf_) buffer ();
+#endif
+#endif
#ifndef XSDE_EXCEPTIONS
if (buf_ == 0)
diff --git a/libxsde/xsde/cxx/parser/validating/hex-binary.cxx b/libxsde/xsde/cxx/parser/validating/hex-binary.cxx
index 24035fa..f7e6139 100644
--- a/libxsde/xsde/cxx/parser/validating/hex-binary.cxx
+++ b/libxsde/xsde/cxx/parser/validating/hex-binary.cxx
@@ -5,6 +5,10 @@
#include <xsde/cxx/config.hxx>
+#ifdef XSDE_CUSTOM_ALLOCATOR
+# include <xsde/cxx/allocator.hxx>
+#endif
+
#include <xsde/cxx/parser/validating/hex-binary.hxx>
static unsigned char
@@ -33,8 +37,15 @@ namespace xsde
hex_binary_pimpl::
~hex_binary_pimpl ()
{
- if (!base_)
+ if (!base_ && buf_)
+ {
+#ifndef XSDE_CUSTOM_ALLOCATOR
delete buf_;
+#else
+ buf_->~buffer ();
+ cxx::free (buf_);
+#endif
+ }
}
void hex_binary_pimpl::
@@ -42,9 +53,14 @@ namespace xsde
{
hex_binary_pskel::_reset ();
- if (!base_)
+ if (!base_ && buf_)
{
+#ifndef XSDE_CUSTOM_ALLOCATOR
delete buf_;
+#else
+ buf_->~buffer ();
+ cxx::free (buf_);
+#endif
buf_ = 0;
}
}
@@ -66,7 +82,20 @@ namespace xsde
{
if (buf_ == 0)
{
+#ifndef XSDE_CUSTOM_ALLOCATOR
buf_ = new buffer ();
+#else
+ buf_ = static_cast<buffer*> (alloc (sizeof (buffer)));
+
+#ifdef XSDE_EXCEPTIONS
+ alloc_guard ag (buf_);
+ new (buf_) buffer ();
+ ag.release ();
+#else
+ if (buf_)
+ new (buf_) buffer ();
+#endif
+#endif
#ifndef XSDE_EXCEPTIONS
if (buf_ == 0)
diff --git a/libxsde/xsde/cxx/parser/validating/idrefs-stl.cxx b/libxsde/xsde/cxx/parser/validating/idrefs-stl.cxx
index 85129ed..3fc3175 100644
--- a/libxsde/xsde/cxx/parser/validating/idrefs-stl.cxx
+++ b/libxsde/xsde/cxx/parser/validating/idrefs-stl.cxx
@@ -7,6 +7,10 @@
#include <xsde/cxx/config.hxx>
+#ifdef XSDE_CUSTOM_ALLOCATOR
+# include <xsde/cxx/allocator.hxx>
+#endif
+
#include <xsde/cxx/parser/validating/idrefs-stl.hxx>
namespace xsde
@@ -20,8 +24,15 @@ namespace xsde
idrefs_pimpl::
~idrefs_pimpl ()
{
- if (!base_)
+ if (!base_ && seq_)
+ {
+#ifndef XSDE_CUSTOM_ALLOCATOR
delete seq_;
+#else
+ seq_->~string_sequence ();
+ cxx::free (seq_);
+#endif
+ }
}
void idrefs_pimpl::
@@ -29,9 +40,14 @@ namespace xsde
{
idrefs_pskel::_reset ();
- if (!base_)
+ if (!base_ && seq_)
{
+#ifndef XSDE_CUSTOM_ALLOCATOR
delete seq_;
+#else
+ seq_->~string_sequence ();
+ cxx::free (seq_);
+#endif
seq_ = 0;
}
@@ -55,7 +71,21 @@ namespace xsde
{
if (seq_ == 0)
{
+#ifndef XSDE_CUSTOM_ALLOCATOR
seq_ = new string_sequence ();
+#else
+ seq_ = static_cast<string_sequence*> (
+ alloc (sizeof (string_sequence)));
+
+#ifdef XSDE_EXCEPTIONS
+ alloc_guard ag (seq_);
+ new (seq_) string_sequence ();
+ ag.release ();
+#else
+ if (seq_)
+ new () string_sequence ();
+#endif
+#endif
#ifndef XSDE_EXCEPTIONS
if (seq_ == 0)
diff --git a/libxsde/xsde/cxx/parser/validating/idrefs.cxx b/libxsde/xsde/cxx/parser/validating/idrefs.cxx
index 2bf35d2..851d28c 100644
--- a/libxsde/xsde/cxx/parser/validating/idrefs.cxx
+++ b/libxsde/xsde/cxx/parser/validating/idrefs.cxx
@@ -7,6 +7,10 @@
#include <xsde/cxx/config.hxx>
+#ifdef XSDE_CUSTOM_ALLOCATOR
+# include <xsde/cxx/allocator.hxx>
+#endif
+
#include <xsde/cxx/parser/validating/idrefs.hxx>
namespace xsde
@@ -20,8 +24,15 @@ namespace xsde
idrefs_pimpl::
~idrefs_pimpl ()
{
- if (!base_)
+ if (!base_ && seq_)
+ {
+#ifndef XSDE_CUSTOM_ALLOCATOR
delete seq_;
+#else
+ seq_->~string_sequence ();
+ cxx::free (seq_);
+#endif
+ }
}
void idrefs_pimpl::
@@ -29,9 +40,14 @@ namespace xsde
{
idrefs_pskel::_reset ();
- if (!base_)
+ if (!base_ && seq_)
{
+#ifndef XSDE_CUSTOM_ALLOCATOR
delete seq_;
+#else
+ seq_->~string_sequence ();
+ cxx::free (seq_);
+#endif
seq_ = 0;
}
@@ -55,7 +71,21 @@ namespace xsde
{
if (seq_ == 0)
{
+#ifndef XSDE_CUSTOM_ALLOCATOR
seq_ = new string_sequence ();
+#else
+ seq_ = static_cast<string_sequence*> (
+ alloc (sizeof (string_sequence)));
+
+#ifdef XSDE_EXCEPTIONS
+ alloc_guard ag (seq_);
+ new (seq_) string_sequence ();
+ ag.release ();
+#else
+ if (seq_)
+ new () string_sequence ();
+#endif
+#endif
#ifndef XSDE_EXCEPTIONS
if (seq_ == 0)
diff --git a/libxsde/xsde/cxx/parser/validating/inheritance-map.cxx b/libxsde/xsde/cxx/parser/validating/inheritance-map.cxx
index c3b9e41..f23e841 100644
--- a/libxsde/xsde/cxx/parser/validating/inheritance-map.cxx
+++ b/libxsde/xsde/cxx/parser/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/parser/validating/inheritance-map.hxx>
#include <xsde/cxx/parser/validating/inheritance-map-load.hxx>
@@ -50,7 +54,21 @@ namespace xsde
{
if (count == 0)
{
+#ifndef XSDE_CUSTOM_ALLOCATOR
map = new inheritance_map (XSDE_PARSER_IMAP_BUCKETS);
+#else
+ map = static_cast<inheritance_map*> (
+ alloc (sizeof (inheritance_map)));
+
+#ifdef XSDE_EXCEPTIONS
+ alloc_guard mg (map);
+ new (map) inheritance_map (XSDE_PARSER_IMAP_BUCKETS);
+ mg.release ();
+#else
+ if (map)
+ new (map) inheritance_map (XSDE_PARSER_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
diff --git a/libxsde/xsde/cxx/parser/validating/nmtokens-stl.cxx b/libxsde/xsde/cxx/parser/validating/nmtokens-stl.cxx
index 8410d89..6258e26 100644
--- a/libxsde/xsde/cxx/parser/validating/nmtokens-stl.cxx
+++ b/libxsde/xsde/cxx/parser/validating/nmtokens-stl.cxx
@@ -5,6 +5,10 @@
#include <xsde/cxx/config.hxx>
+#ifdef XSDE_CUSTOM_ALLOCATOR
+# include <xsde/cxx/allocator.hxx>
+#endif
+
#include <xsde/cxx/parser/validating/nmtokens-stl.hxx>
namespace xsde
@@ -18,8 +22,15 @@ namespace xsde
nmtokens_pimpl::
~nmtokens_pimpl ()
{
- if (!base_)
+ if (!base_ && seq_)
+ {
+#ifndef XSDE_CUSTOM_ALLOCATOR
delete seq_;
+#else
+ seq_->~string_sequence ();
+ cxx::free (seq_);
+#endif
+ }
}
void nmtokens_pimpl::
@@ -27,9 +38,14 @@ namespace xsde
{
nmtokens_pskel::_reset ();
- if (!base_)
+ if (!base_ && seq_)
{
+#ifndef XSDE_CUSTOM_ALLOCATOR
delete seq_;
+#else
+ seq_->~string_sequence ();
+ cxx::free (seq_);
+#endif
seq_ = 0;
}
@@ -53,7 +69,21 @@ namespace xsde
{
if (seq_ == 0)
{
+#ifndef XSDE_CUSTOM_ALLOCATOR
seq_ = new string_sequence ();
+#else
+ seq_ = static_cast<string_sequence*> (
+ alloc (sizeof (string_sequence)));
+
+#ifdef XSDE_EXCEPTIONS
+ alloc_guard ag (seq_);
+ new (seq_) string_sequence ();
+ ag.release ();
+#else
+ if (seq_)
+ new () string_sequence ();
+#endif
+#endif
#ifndef XSDE_EXCEPTIONS
if (seq_ == 0)
diff --git a/libxsde/xsde/cxx/parser/validating/nmtokens.cxx b/libxsde/xsde/cxx/parser/validating/nmtokens.cxx
index 7573f28..5d06ef1 100644
--- a/libxsde/xsde/cxx/parser/validating/nmtokens.cxx
+++ b/libxsde/xsde/cxx/parser/validating/nmtokens.cxx
@@ -5,6 +5,10 @@
#include <xsde/cxx/config.hxx>
+#ifdef XSDE_CUSTOM_ALLOCATOR
+# include <xsde/cxx/allocator.hxx>
+#endif
+
#include <xsde/cxx/parser/validating/nmtokens.hxx>
namespace xsde
@@ -18,8 +22,15 @@ namespace xsde
nmtokens_pimpl::
~nmtokens_pimpl ()
{
- if (!base_)
+ if (!base_ && seq_)
+ {
+#ifndef XSDE_CUSTOM_ALLOCATOR
delete seq_;
+#else
+ seq_->~string_sequence ();
+ cxx::free (seq_);
+#endif
+ }
}
void nmtokens_pimpl::
@@ -27,9 +38,14 @@ namespace xsde
{
nmtokens_pskel::_reset ();
- if (!base_)
+ if (!base_ && seq_)
{
+#ifndef XSDE_CUSTOM_ALLOCATOR
delete seq_;
+#else
+ seq_->~string_sequence ();
+ cxx::free (seq_);
+#endif
seq_ = 0;
}
@@ -53,7 +69,21 @@ namespace xsde
{
if (seq_ == 0)
{
+#ifndef XSDE_CUSTOM_ALLOCATOR
seq_ = new string_sequence ();
+#else
+ seq_ = static_cast<string_sequence*> (
+ alloc (sizeof (string_sequence)));
+
+#ifdef XSDE_EXCEPTIONS
+ alloc_guard ag (seq_);
+ new (seq_) string_sequence ();
+ ag.release ();
+#else
+ if (seq_)
+ new () string_sequence ();
+#endif
+#endif
#ifndef XSDE_EXCEPTIONS
if (seq_ == 0)
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)
diff --git a/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.hxx b/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.hxx
index a978c6d..4b6b126 100644
--- a/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.hxx
+++ b/libxsde/xsde/cxx/parser/validating/xml-schema-pskel.hxx
@@ -655,7 +655,8 @@ namespace xsde
//
// String-based types. If STL is disabled you are getting a C
- // string that you have to delete with delete[].
+ // string that you have to delete with delete[] (or custom
+ // deallocator if enabled).
//
struct string_facets