diff --git a/MessagePackPacker.m b/MessagePackPacker.m index 28af09b..f9957cc 100644 --- a/MessagePackPacker.m +++ b/MessagePackPacker.m @@ -72,7 +72,7 @@ + (void)packObject:(id)obj into:(msgpack_packer*)pk { } } else if ([obj isKindOfClass:[NSString class]]) { const char *str = ((NSString*)obj).UTF8String; - int len = strlen(str); + size_t len = strlen(str); msgpack_pack_raw(pk, len); msgpack_pack_raw_body(pk, str, len); } else if ([obj isKindOfClass:[NSNumber class]]) { diff --git a/msgpack_src/msgpack/pack.h b/msgpack_src/msgpack/pack.h index f86e929..6b356ce 100644 --- a/msgpack_src/msgpack/pack.h +++ b/msgpack_src/msgpack/pack.h @@ -86,9 +86,9 @@ static int msgpack_pack_nil(msgpack_packer* pk); static int msgpack_pack_true(msgpack_packer* pk); static int msgpack_pack_false(msgpack_packer* pk); -static int msgpack_pack_array(msgpack_packer* pk, unsigned int n); +static int msgpack_pack_array(msgpack_packer* pk, size_t n); -static int msgpack_pack_map(msgpack_packer* pk, unsigned int n); +static int msgpack_pack_map(msgpack_packer* pk, size_t n); static int msgpack_pack_raw(msgpack_packer* pk, size_t l); static int msgpack_pack_raw_body(msgpack_packer* pk, const void* b, size_t l); diff --git a/msgpack_src/msgpack/pack_template.h b/msgpack_src/msgpack/pack_template.h index da54c36..c72c933 100644 --- a/msgpack_src/msgpack/pack_template.h +++ b/msgpack_src/msgpack/pack_template.h @@ -683,7 +683,7 @@ msgpack_pack_inline_func(_false)(msgpack_pack_user x) * Array */ -msgpack_pack_inline_func(_array)(msgpack_pack_user x, unsigned int n) +msgpack_pack_inline_func(_array)(msgpack_pack_user x, size_t n) { if(n < 16) { unsigned char d = 0x90 | n; @@ -704,7 +704,7 @@ msgpack_pack_inline_func(_array)(msgpack_pack_user x, unsigned int n) * Map */ -msgpack_pack_inline_func(_map)(msgpack_pack_user x, unsigned int n) +msgpack_pack_inline_func(_map)(msgpack_pack_user x, size_t n) { if(n < 16) { unsigned char d = 0x80 | n; @@ -743,7 +743,12 @@ msgpack_pack_inline_func(_raw)(msgpack_pack_user x, size_t l) msgpack_pack_inline_func(_raw_body)(msgpack_pack_user x, const void* b, size_t l) { - msgpack_pack_append_buffer(x, (const unsigned char*)b, l); + if(l < 65536) { + msgpack_pack_append_buffer(x, (const unsigned char*)b, (uint16_t)l); + } else { + msgpack_pack_append_buffer(x, (const unsigned char*)b, (uint32_t)l); + } + } #undef msgpack_pack_inline_func