diff --git a/include/msgpack/vrefbuffer.h b/include/msgpack/vrefbuffer.h index cdd88637..c2633052 100644 --- a/include/msgpack/vrefbuffer.h +++ b/include/msgpack/vrefbuffer.h @@ -16,11 +16,13 @@ #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 @@ -44,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; @@ -74,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 @@ -126,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; } diff --git a/src/vrefbuffer.c b/src/vrefbuffer.c index 6c3ce3a0..d14b7190 100644 --- a/src/vrefbuffer.c +++ b/src/vrefbuffer.c @@ -22,7 +22,7 @@ bool msgpack_vrefbuffer_init(msgpack_vrefbuffer* vbuf, size_t ref_size, size_t chunk_size) { size_t nfirst; - struct iovec* array; + msgpack_iovec* array; msgpack_vrefbuffer_chunk* chunk; if (ref_size == 0) { @@ -40,11 +40,11 @@ bool msgpack_vrefbuffer_init(msgpack_vrefbuffer* vbuf, return false; } - nfirst = (sizeof(struct iovec) < 72/2) ? - 72 / sizeof(struct iovec) : 8; + nfirst = (sizeof(msgpack_iovec) < 72/2) ? + 72 / sizeof(msgpack_iovec) : 8; - array = (struct iovec*)malloc( - sizeof(struct iovec) * nfirst); + array = (msgpack_iovec*)malloc( + sizeof(msgpack_iovec) * nfirst); if(array == NULL) { return false; } @@ -114,8 +114,8 @@ int msgpack_vrefbuffer_append_ref(msgpack_vrefbuffer* vbuf, const size_t nused = (size_t)(vbuf->tail - vbuf->array); const size_t nnext = nused * 2; - struct iovec* nvec = (struct iovec*)realloc( - vbuf->array, sizeof(struct iovec)*nnext); + msgpack_iovec* nvec = (msgpack_iovec*)realloc( + vbuf->array, sizeof(msgpack_iovec)*nnext); if(nvec == NULL) { return -1; } @@ -194,7 +194,7 @@ int msgpack_vrefbuffer_migrate(msgpack_vrefbuffer* vbuf, msgpack_vrefbuffer* to) { const size_t nused = (size_t)(vbuf->tail - vbuf->array); if(to->tail + nused < vbuf->end) { - struct iovec* nvec; + msgpack_iovec* nvec; const size_t tosize = (size_t)(to->tail - to->array); const size_t reqsize = nused + tosize; size_t nnext = (size_t)(to->end - to->array) * 2; @@ -207,8 +207,8 @@ int msgpack_vrefbuffer_migrate(msgpack_vrefbuffer* vbuf, msgpack_vrefbuffer* to) nnext = tmp_nnext; } - nvec = (struct iovec*)realloc( - to->array, sizeof(struct iovec)*nnext); + nvec = (msgpack_iovec*)realloc( + to->array, sizeof(msgpack_iovec)*nnext); if(nvec == NULL) { free(empty); return -1; @@ -219,7 +219,7 @@ int msgpack_vrefbuffer_migrate(msgpack_vrefbuffer* vbuf, msgpack_vrefbuffer* to) to->tail = nvec + tosize; } - memcpy(to->tail, vbuf->array, sizeof(struct iovec)*nused); + memcpy(to->tail, vbuf->array, sizeof(msgpack_iovec)*nused); to->tail += nused; vbuf->tail = vbuf->array; diff --git a/test/buffer_c.cpp b/test/buffer_c.cpp index 01e8d24c..e0c09acc 100644 --- a/test/buffer_c.cpp +++ b/test/buffer_c.cpp @@ -102,7 +102,7 @@ TEST(buffer, vrefbuffer_c) MSGPACK_VREFBUFFER_REF_SIZE + 1, ref_size, chunk_size + 1}; size_t iovcnt; - const iovec *iov; + const msgpack_iovec *iov; size_t len = 0, i; char *buf; diff --git a/test/msgpack_c.cpp b/test/msgpack_c.cpp index a5ca4f7a..452f0407 100644 --- a/test/msgpack_c.cpp +++ b/test/msgpack_c.cpp @@ -1616,7 +1616,7 @@ TEST(MSGPACKC, object_bin_print_buffer_overflow) { #define GEN_TEST_VREFBUFFER_PREPARE(...) \ msgpack_vrefbuffer vbuf; \ msgpack_packer pk; \ - const iovec *iov; \ + const msgpack_iovec *iov; \ size_t iovcnt, len = 0, i; \ char buf[1024]; \ msgpack_vrefbuffer_init(&vbuf, 0, 0); \