Update vendored msgpack-c to 4.0.0
[lttng-tools.git] / src / vendor / msgpack / vrefbuffer.h
index ab51aefa38140699edcf0b454d30cff40a23894a..c2633052bdbd9f863dba2a8c50efb06c3183376b 100644 (file)
 
 #include "zone.h"
 #include <stdlib.h>
 
 #include "zone.h"
 #include <stdlib.h>
+#include <assert.h>
 
 #if defined(unix) || defined(__unix) || defined(__linux__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__QNX__) || defined(__QNXTO__) || defined(__HAIKU__)
 #include <sys/uio.h>
 
 #if defined(unix) || defined(__unix) || defined(__linux__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__QNX__) || defined(__QNXTO__) || defined(__HAIKU__)
 #include <sys/uio.h>
+typedef struct iovec msgpack_iovec;
 #else
 #else
-struct iovec {
+struct msgpack_iovec {
     void  *iov_base;
     size_t iov_len;
 };
     void  *iov_base;
     size_t iov_len;
 };
+typedef struct msgpack_iovec msgpack_iovec;
 #endif
 
 #ifdef __cplusplus
 #endif
 
 #ifdef __cplusplus
@@ -43,9 +46,9 @@ typedef struct msgpack_vrefbuffer_inner_buffer {
 } msgpack_vrefbuffer_inner_buffer;
 
 typedef struct msgpack_vrefbuffer {
 } 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;
 
     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 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
 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;
 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);
 
     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;
 }
 {
     return vref->array;
 }
This page took 0.024099 seconds and 4 git commands to generate.