Skip to content

Commit 0f1d0ed

Browse files
committed
Fix name conflicts (C version)
Same as #952, but for C
1 parent 825017a commit 0f1d0ed

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
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;

0 commit comments

Comments
 (0)