diff --git a/pack_template.h b/pack_template.h index e12a7a0e..0c975b47 100644 --- a/pack_template.h +++ b/pack_template.h @@ -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 diff --git a/src/msgpack/sbuffer.h b/src/msgpack/sbuffer.h index 4ade093b..4ffb0b7c 100644 --- a/src/msgpack/sbuffer.h +++ b/src/msgpack/sbuffer.h @@ -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; diff --git a/src/msgpack/zone.h b/src/msgpack/zone.h index 86678805..aa2a1470 100644 --- a/src/msgpack/zone.h +++ b/src/msgpack/zone.h @@ -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;