Skip to content

Commit 5d30e42

Browse files
authored
Merge pull request #953 from kovdan01/fix_name_conflicts_c
Fix name conflicts (C)
2 parents 825017a + 6b4a7b3 commit 5d30e42

File tree

4 files changed

+21
-19
lines changed

4 files changed

+21
-19
lines changed

include/msgpack/vrefbuffer.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616

1717
#if defined(unix) || defined(__unix) || defined(__linux__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__QNX__) || defined(__QNXTO__) || defined(__HAIKU__)
1818
#include <sys/uio.h>
19+
typedef struct iovec msgpack_iovec;
1920
#else
20-
struct iovec {
21+
struct msgpack_iovec {
2122
void *iov_base;
2223
size_t iov_len;
2324
};
25+
typedef struct msgpack_iovec msgpack_iovec;
2426
#endif
2527

2628
#ifdef __cplusplus
@@ -44,9 +46,9 @@ typedef struct msgpack_vrefbuffer_inner_buffer {
4446
} msgpack_vrefbuffer_inner_buffer;
4547

4648
typedef struct msgpack_vrefbuffer {
47-
struct iovec* tail;
48-
struct iovec* end;
49-
struct iovec* array;
49+
msgpack_iovec* tail;
50+
msgpack_iovec* end;
51+
msgpack_iovec* array;
5052

5153
size_t chunk_size;
5254
size_t ref_size;
@@ -74,7 +76,7 @@ static inline void msgpack_vrefbuffer_free(msgpack_vrefbuffer* vbuf);
7476

7577
static inline int msgpack_vrefbuffer_write(void* data, const char* buf, size_t len);
7678

77-
static inline const struct iovec* msgpack_vrefbuffer_vec(const msgpack_vrefbuffer* vref);
79+
static inline const msgpack_iovec* msgpack_vrefbuffer_vec(const msgpack_vrefbuffer* vref);
7880
static inline size_t msgpack_vrefbuffer_veclen(const msgpack_vrefbuffer* vref);
7981

8082
MSGPACK_DLLEXPORT
@@ -126,7 +128,7 @@ static inline int msgpack_vrefbuffer_write(void* data, const char* buf, size_t l
126128
}
127129
}
128130

129-
static inline const struct iovec* msgpack_vrefbuffer_vec(const msgpack_vrefbuffer* vref)
131+
static inline const msgpack_iovec* msgpack_vrefbuffer_vec(const msgpack_vrefbuffer* vref)
130132
{
131133
return vref->array;
132134
}

src/vrefbuffer.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ bool msgpack_vrefbuffer_init(msgpack_vrefbuffer* vbuf,
2222
size_t ref_size, size_t chunk_size)
2323
{
2424
size_t nfirst;
25-
struct iovec* array;
25+
msgpack_iovec* array;
2626
msgpack_vrefbuffer_chunk* chunk;
2727

2828
if (ref_size == 0) {
@@ -40,11 +40,11 @@ bool msgpack_vrefbuffer_init(msgpack_vrefbuffer* vbuf,
4040
return false;
4141
}
4242

43-
nfirst = (sizeof(struct iovec) < 72/2) ?
44-
72 / sizeof(struct iovec) : 8;
43+
nfirst = (sizeof(msgpack_iovec) < 72/2) ?
44+
72 / sizeof(msgpack_iovec) : 8;
4545

46-
array = (struct iovec*)malloc(
47-
sizeof(struct iovec) * nfirst);
46+
array = (msgpack_iovec*)malloc(
47+
sizeof(msgpack_iovec) * nfirst);
4848
if(array == NULL) {
4949
return false;
5050
}
@@ -114,8 +114,8 @@ int msgpack_vrefbuffer_append_ref(msgpack_vrefbuffer* vbuf,
114114
const size_t nused = (size_t)(vbuf->tail - vbuf->array);
115115
const size_t nnext = nused * 2;
116116

117-
struct iovec* nvec = (struct iovec*)realloc(
118-
vbuf->array, sizeof(struct iovec)*nnext);
117+
msgpack_iovec* nvec = (msgpack_iovec*)realloc(
118+
vbuf->array, sizeof(msgpack_iovec)*nnext);
119119
if(nvec == NULL) {
120120
return -1;
121121
}
@@ -194,7 +194,7 @@ int msgpack_vrefbuffer_migrate(msgpack_vrefbuffer* vbuf, msgpack_vrefbuffer* to)
194194
{
195195
const size_t nused = (size_t)(vbuf->tail - vbuf->array);
196196
if(to->tail + nused < vbuf->end) {
197-
struct iovec* nvec;
197+
msgpack_iovec* nvec;
198198
const size_t tosize = (size_t)(to->tail - to->array);
199199
const size_t reqsize = nused + tosize;
200200
size_t nnext = (size_t)(to->end - to->array) * 2;
@@ -207,8 +207,8 @@ int msgpack_vrefbuffer_migrate(msgpack_vrefbuffer* vbuf, msgpack_vrefbuffer* to)
207207
nnext = tmp_nnext;
208208
}
209209

210-
nvec = (struct iovec*)realloc(
211-
to->array, sizeof(struct iovec)*nnext);
210+
nvec = (msgpack_iovec*)realloc(
211+
to->array, sizeof(msgpack_iovec)*nnext);
212212
if(nvec == NULL) {
213213
free(empty);
214214
return -1;
@@ -219,7 +219,7 @@ int msgpack_vrefbuffer_migrate(msgpack_vrefbuffer* vbuf, msgpack_vrefbuffer* to)
219219
to->tail = nvec + tosize;
220220
}
221221

222-
memcpy(to->tail, vbuf->array, sizeof(struct iovec)*nused);
222+
memcpy(to->tail, vbuf->array, sizeof(msgpack_iovec)*nused);
223223

224224
to->tail += nused;
225225
vbuf->tail = vbuf->array;

test/buffer_c.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ TEST(buffer, vrefbuffer_c)
102102
MSGPACK_VREFBUFFER_REF_SIZE + 1,
103103
ref_size, chunk_size + 1};
104104
size_t iovcnt;
105-
const iovec *iov;
105+
const msgpack_iovec *iov;
106106
size_t len = 0, i;
107107
char *buf;
108108

test/msgpack_c.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1616,7 +1616,7 @@ TEST(MSGPACKC, object_bin_print_buffer_overflow) {
16161616
#define GEN_TEST_VREFBUFFER_PREPARE(...) \
16171617
msgpack_vrefbuffer vbuf; \
16181618
msgpack_packer pk; \
1619-
const iovec *iov; \
1619+
const msgpack_iovec *iov; \
16201620
size_t iovcnt, len = 0, i; \
16211621
char buf[1024]; \
16221622
msgpack_vrefbuffer_init(&vbuf, 0, 0); \

0 commit comments

Comments
 (0)