mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-19 04:52:59 +01:00
Merge pull request #90 from tbeu/fix-c-compilation
Fix pure C compilation
This commit is contained in:
commit
1656ef0111
@ -656,18 +656,18 @@ if(sizeof(unsigned long long) == 2) {
|
||||
|
||||
msgpack_pack_inline_func(_float)(msgpack_pack_user x, float d)
|
||||
{
|
||||
unsigned char buf[5];
|
||||
union { float f; uint32_t i; } mem;
|
||||
mem.f = d;
|
||||
unsigned char buf[5];
|
||||
buf[0] = 0xca; _msgpack_store32(&buf[1], mem.i);
|
||||
msgpack_pack_append_buffer(x, buf, 5);
|
||||
}
|
||||
|
||||
msgpack_pack_inline_func(_double)(msgpack_pack_user x, double d)
|
||||
{
|
||||
unsigned char buf[9];
|
||||
union { double f; uint64_t i; } mem;
|
||||
mem.f = d;
|
||||
unsigned char buf[9];
|
||||
buf[0] = 0xcb;
|
||||
#if defined(__arm__) && !(__ARM_EABI__) // arm-oabi
|
||||
// https://github.com/msgpack/msgpack-perl/pull/1
|
||||
|
@ -69,12 +69,13 @@ static inline int msgpack_sbuffer_write(void* data, const char* buf, size_t len)
|
||||
msgpack_sbuffer* sbuf = (msgpack_sbuffer*)data;
|
||||
|
||||
if(sbuf->alloc - sbuf->size < len) {
|
||||
void* tmp;
|
||||
size_t nsize = (sbuf->alloc) ?
|
||||
sbuf->alloc * 2 : MSGPACK_SBUFFER_INIT_SIZE;
|
||||
|
||||
while(nsize < sbuf->size + len) { nsize *= 2; }
|
||||
|
||||
void* tmp = realloc(sbuf->data, nsize);
|
||||
tmp = realloc(sbuf->data, nsize);
|
||||
if(!tmp) { return -1; }
|
||||
|
||||
sbuf->data = (char*)tmp;
|
||||
|
@ -90,13 +90,14 @@ void* msgpack_zone_malloc_expand(msgpack_zone* zone, size_t size);
|
||||
|
||||
void* msgpack_zone_malloc_no_align(msgpack_zone* zone, size_t size)
|
||||
{
|
||||
char* ptr;
|
||||
msgpack_zone_chunk_list* cl = &zone->chunk_list;
|
||||
|
||||
if(zone->chunk_list.free < size) {
|
||||
return msgpack_zone_malloc_expand(zone, size);
|
||||
}
|
||||
|
||||
char* ptr = cl->ptr;
|
||||
ptr = cl->ptr;
|
||||
cl->free -= size;
|
||||
cl->ptr += size;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user