mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-05-29 23:42:40 +02:00
cpp: adds msgpack_zbuffer_new and msgpack_zbuffer_free
This commit is contained in:
parent
e49f091b4e
commit
103b14ea3c
@ -47,6 +47,9 @@ static inline bool msgpack_zbuffer_init(msgpack_zbuffer* zbuf,
|
|||||||
int level, size_t init_size);
|
int level, size_t init_size);
|
||||||
static inline void msgpack_zbuffer_destroy(msgpack_zbuffer* zbuf);
|
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 char* msgpack_zbuffer_flush(msgpack_zbuffer* zbuf);
|
||||||
|
|
||||||
static inline const char* msgpack_zbuffer_data(const 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);
|
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)
|
bool msgpack_zbuffer_expand(msgpack_zbuffer* zbuf)
|
||||||
{
|
{
|
||||||
size_t used = (char*)zbuf->stream.next_out - zbuf->data;
|
size_t used = (char*)zbuf->stream.next_out - zbuf->data;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user