summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorfrsyuki <frsyuki@users.sourceforge.jp>2010-06-01 07:10:39 +0900
committerfrsyuki <frsyuki@users.sourceforge.jp>2010-06-01 07:10:39 +0900
commit103b14ea3c8a3f72213295d975328dc2399725eb (patch)
treeec284167a13d3ee6c46e16e229331fdadc6b69f6 /cpp/src
parente49f091b4ebc7abbad92848502a6e06d4e9d6cfa (diff)
downloadmsgpack-python-103b14ea3c8a3f72213295d975328dc2399725eb.tar.gz
cpp: adds msgpack_zbuffer_new and msgpack_zbuffer_free
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/msgpack/zbuffer.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/cpp/src/msgpack/zbuffer.h b/cpp/src/msgpack/zbuffer.h
index 2a32206..0ff9675 100644
--- a/cpp/src/msgpack/zbuffer.h
+++ b/cpp/src/msgpack/zbuffer.h
@@ -47,6 +47,9 @@ static inline bool msgpack_zbuffer_init(msgpack_zbuffer* zbuf,
int level, size_t init_size);
static inline void msgpack_zbuffer_destroy(msgpack_zbuffer* zbuf);
+static inline msgpack_zbuffer* msgpack_zbuffer_new(int level, size_t init_size);
+static inline void msgpack_zbuffer_free(msgpack_zbuffer* zbuf);
+
static inline char* msgpack_zbuffer_flush(msgpack_zbuffer* zbuf);
static inline const char* msgpack_zbuffer_data(const msgpack_zbuffer* zbuf);
@@ -80,6 +83,23 @@ void msgpack_zbuffer_destroy(msgpack_zbuffer* zbuf)
free(zbuf->data);
}
+msgpack_zbuffer* msgpack_zbuffer_new(int level, size_t init_size)
+{
+ msgpack_zbuffer* zbuf = (msgpack_zbuffer*)malloc(sizeof(msgpack_zbuffer));
+ if(!msgpack_zbuffer_init(zbuf, level, init_size)) {
+ free(zbuf);
+ return NULL;
+ }
+ return zbuf;
+}
+
+void msgpack_zbuffer_free(msgpack_zbuffer* zbuf)
+{
+ if(zbuf == NULL) { return; }
+ msgpack_zbuffer_destroy(zbuf);
+ free(zbuf);
+}
+
bool msgpack_zbuffer_expand(msgpack_zbuffer* zbuf)
{
size_t used = (char*)zbuf->stream.next_out - zbuf->data;