X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fvendor%2Fmsgpack%2Fvrefbuffer.h;fp=src%2Fvendor%2Fmsgpack%2Fvrefbuffer.h;h=c2633052bdbd9f863dba2a8c50efb06c3183376b;hp=ab51aefa38140699edcf0b454d30cff40a23894a;hb=0c07860d8c0160fea35c59fc5d43b948f354359e;hpb=0ae8863018325f0e86112e6a1ce466d5576b5461 diff --git a/src/vendor/msgpack/vrefbuffer.h b/src/vendor/msgpack/vrefbuffer.h index ab51aefa3..c2633052b 100644 --- a/src/vendor/msgpack/vrefbuffer.h +++ b/src/vendor/msgpack/vrefbuffer.h @@ -12,14 +12,17 @@ #include "zone.h" #include +#include #if defined(unix) || defined(__unix) || defined(__linux__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__QNX__) || defined(__QNXTO__) || defined(__HAIKU__) #include +typedef struct iovec msgpack_iovec; #else -struct iovec { +struct msgpack_iovec { void *iov_base; size_t iov_len; }; +typedef struct msgpack_iovec msgpack_iovec; #endif #ifdef __cplusplus @@ -43,9 +46,9 @@ typedef struct msgpack_vrefbuffer_inner_buffer { } msgpack_vrefbuffer_inner_buffer; typedef struct msgpack_vrefbuffer { - struct iovec* tail; - struct iovec* end; - struct iovec* array; + msgpack_iovec* tail; + msgpack_iovec* end; + msgpack_iovec* array; size_t chunk_size; size_t ref_size; @@ -73,7 +76,7 @@ static inline void msgpack_vrefbuffer_free(msgpack_vrefbuffer* vbuf); static inline int msgpack_vrefbuffer_write(void* data, const char* buf, size_t len); -static inline const struct iovec* msgpack_vrefbuffer_vec(const msgpack_vrefbuffer* vref); +static inline const msgpack_iovec* msgpack_vrefbuffer_vec(const msgpack_vrefbuffer* vref); static inline size_t msgpack_vrefbuffer_veclen(const msgpack_vrefbuffer* vref); MSGPACK_DLLEXPORT @@ -114,6 +117,9 @@ static inline void msgpack_vrefbuffer_free(msgpack_vrefbuffer* vbuf) static inline int msgpack_vrefbuffer_write(void* data, const char* buf, size_t len) { msgpack_vrefbuffer* vbuf = (msgpack_vrefbuffer*)data; + assert(buf || len == 0); + + if(!buf) return 0; if(len < vbuf->ref_size) { return msgpack_vrefbuffer_append_copy(vbuf, buf, len); @@ -122,7 +128,7 @@ static inline int msgpack_vrefbuffer_write(void* data, const char* buf, size_t l } } -static inline const struct iovec* msgpack_vrefbuffer_vec(const msgpack_vrefbuffer* vref) +static inline const msgpack_iovec* msgpack_vrefbuffer_vec(const msgpack_vrefbuffer* vref) { return vref->array; }