diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2009-03-11 09:30:41 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2009-03-11 09:30:41 +0200 |
commit | 9db750f407ceeb5c1fab99414b074d289bfda179 (patch) | |
tree | eb1a5e52ebf84d79d378d5ab2ae56372028776e0 /libxsde/xsde/cxx/stack.cxx | |
parent | bc628cff98a1d90d4ee293f22979db56b4ed0695 (diff) |
Add support for parsing/serialization of recursive types
tests/cxx/hybrid/recursive/: new test
Diffstat (limited to 'libxsde/xsde/cxx/stack.cxx')
-rw-r--r-- | libxsde/xsde/cxx/stack.cxx | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/libxsde/xsde/cxx/stack.cxx b/libxsde/xsde/cxx/stack.cxx new file mode 100644 index 0000000..a27acc8 --- /dev/null +++ b/libxsde/xsde/cxx/stack.cxx @@ -0,0 +1,42 @@ +// file : xsde/cxx/stack.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <string.h> // memcpy + +#include <xsde/cxx/stack.hxx> + +namespace xsde +{ + namespace cxx + { +#ifdef XSDE_EXCEPTIONS + void stack:: +#else + stack::error stack:: +#endif + grow () + { + size_t c = capacity_ ? capacity_ * 2 : 8; + char* d = new char[c * el_size_]; + +#ifndef XSDE_EXCEPTIONS + if (d == 0) + return error_no_memory; +#endif + + if (size_ > 1) + memcpy (d, data_, (size_ - 1) * el_size_); + + delete[] data_; + + data_ = d; + capacity_ = c; + +#ifndef XSDE_EXCEPTIONS + return error_none; +#endif + } + } +} |