mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-02-07 02:09:59 +00:00
cpp: adds msgpack_zbuffer_new and msgpack_zbuffer_free
This commit is contained in:
parent
e49f091b4e
commit
103b14ea3c
1 changed files with 20 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue