aboutsummaryrefslogtreecommitdiff
path: root/odb/buffer.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-07-26 15:40:44 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-07-26 15:40:44 +0200
commit33e33d260dddd6adb226814415811926c1a779ae (patch)
tree20f718398ba5bb118d2e27e4c3de35fe8ea4fe80 /odb/buffer.hxx
parent32f1168489c12677fbb174c5119b5edd40309b79 (diff)
Buffer implementation
Diffstat (limited to 'odb/buffer.hxx')
-rw-r--r--odb/buffer.hxx27
1 files changed, 25 insertions, 2 deletions
diff --git a/odb/buffer.hxx b/odb/buffer.hxx
index 99482ae..2a07735 100644
--- a/odb/buffer.hxx
+++ b/odb/buffer.hxx
@@ -6,6 +6,7 @@
#ifndef ODB_BUFFER_HXX
#define ODB_BUFFER_HXX
+#include <new>
#include <cstddef> // std::size_t
namespace odb
@@ -13,10 +14,32 @@ namespace odb
class buffer
{
public:
- buffer ();
+ ~buffer ()
+ {
+ if (data_)
+ operator delete (data_);
+ }
+
+ buffer ()
+ : capacity_ (512)
+ {
+ data_ = static_cast<char*> (operator new (capacity_));
+ }
+
+ char*
+ data ()
+ {
+ return data_;
+ }
+
+ std::size_t
+ capacity () const
+ {
+ return capacity_;
+ }
void
- grow (std::size_t new_capacity, std::size_t data_size);
+ capacity (std::size_t, std::size_t data_size = 0);
private:
char* data_;