From cb4d8517618b8a11604d1c7724a16bf65a622ca1 Mon Sep 17 00:00:00 2001
From: Takatoshi Kondo <redboltz@gmail.com>
Date: Sun, 22 Dec 2013 15:13:48 +0000
Subject: [PATCH] Fixed size types based on snej's pull request.
 https://github.com/snej/msgpack-c/commit/1784e7a3f3d012e1149adc9b8a3abb3646eb616f

---
 example/protocol.cc        |  2 +-
 pack_template.h            |  4 ++--
 src/msgpack/pack.h         |  4 ++--
 src/msgpack/pack.hpp       | 14 +++++++-------
 src/msgpack/vrefbuffer.h   |  8 ++++----
 src/msgpack/vrefbuffer.hpp |  2 +-
 src/vrefbuffer.c           |  4 ++--
 7 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/example/protocol.cc b/example/protocol.cc
index e7f2a387..ddf785a7 100644
--- a/example/protocol.cc
+++ b/example/protocol.cc
@@ -17,7 +17,7 @@ namespace myprotocol {
 
 	struct Put : define< tuple<uint32_t, std::string, raw_ref> > {
 		Put() { }
-		Put(uint32_t f, const std::string& k, const char* valref, size_t vallen) :
+		Put(uint32_t f, const std::string& k, const char* valref, uint32_t vallen) :
 			define_type(msgpack_type( f, k, raw_ref(valref,vallen) )) { }
 		uint32_t&    flags() { return get<0>(); }
 		std::string& key()   { return get<1>(); }
diff --git a/pack_template.h b/pack_template.h
index 65c959dd..e5be0d8c 100644
--- a/pack_template.h
+++ b/pack_template.h
@@ -688,7 +688,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;
@@ -709,7 +709,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;
diff --git a/src/msgpack/pack.h b/src/msgpack/pack.h
index f86e9299..6b356ce9 100644
--- a/src/msgpack/pack.h
+++ b/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/src/msgpack/pack.hpp b/src/msgpack/pack.hpp
index 0090b961..904db274 100644
--- a/src/msgpack/pack.hpp
+++ b/src/msgpack/pack.hpp
@@ -70,9 +70,9 @@ public:
 	packer<Stream>& pack_true();
 	packer<Stream>& pack_false();
 
-	packer<Stream>& pack_array(unsigned int n);
+	packer<Stream>& pack_array(size_t n);
 
-	packer<Stream>& pack_map(unsigned int n);
+	packer<Stream>& pack_map(size_t n);
 
 	packer<Stream>& pack_raw(size_t l);
 	packer<Stream>& pack_raw_body(const char* b, size_t l);
@@ -112,14 +112,14 @@ private:
 	static void _pack_true(Stream& x);
 	static void _pack_false(Stream& x);
 
-	static void _pack_array(Stream& x, unsigned int n);
+	static void _pack_array(Stream& x, size_t n);
 
-	static void _pack_map(Stream& x, unsigned int n);
+	static void _pack_map(Stream& x, size_t n);
 
 	static void _pack_raw(Stream& x, size_t l);
 	static void _pack_raw_body(Stream& x, const void* b, size_t l);
 
-	static void append_buffer(Stream& x, const unsigned char* buf, unsigned int len)
+	static void append_buffer(Stream& x, const unsigned char* buf, size_t len)
 		{ x.write((const char*)buf, len); }
 
 private:
@@ -294,12 +294,12 @@ inline packer<Stream>& packer<Stream>::pack_false()
 
 
 template <typename Stream>
-inline packer<Stream>& packer<Stream>::pack_array(unsigned int n)
+inline packer<Stream>& packer<Stream>::pack_array(size_t n)
 { _pack_array(m_stream, n); return *this; }
 
 
 template <typename Stream>
-inline packer<Stream>& packer<Stream>::pack_map(unsigned int n)
+inline packer<Stream>& packer<Stream>::pack_map(size_t n)
 { _pack_map(m_stream, n); return *this; }
 
 
diff --git a/src/msgpack/vrefbuffer.h b/src/msgpack/vrefbuffer.h
index 09b9a710..ec748096 100644
--- a/src/msgpack/vrefbuffer.h
+++ b/src/msgpack/vrefbuffer.h
@@ -77,16 +77,16 @@ void msgpack_vrefbuffer_destroy(msgpack_vrefbuffer* vbuf);
 static inline msgpack_vrefbuffer* msgpack_vrefbuffer_new(size_t ref_size, size_t chunk_size);
 static inline void msgpack_vrefbuffer_free(msgpack_vrefbuffer* vbuf);
 
-static inline int msgpack_vrefbuffer_write(void* data, const char* buf, unsigned int len);
+static inline int msgpack_vrefbuffer_write(void* data, const char* buf, size_t len);
 
 static inline const struct iovec* msgpack_vrefbuffer_vec(const msgpack_vrefbuffer* vref);
 static inline size_t msgpack_vrefbuffer_veclen(const msgpack_vrefbuffer* vref);
 
 int msgpack_vrefbuffer_append_copy(msgpack_vrefbuffer* vbuf,
-		const char* buf, unsigned int len);
+		const char* buf, size_t len);
 
 int msgpack_vrefbuffer_append_ref(msgpack_vrefbuffer* vbuf,
-		const char* buf, unsigned int len);
+		const char* buf, size_t len);
 
 int msgpack_vrefbuffer_migrate(msgpack_vrefbuffer* vbuf, msgpack_vrefbuffer* to);
 
@@ -112,7 +112,7 @@ static inline void msgpack_vrefbuffer_free(msgpack_vrefbuffer* vbuf)
 	free(vbuf);
 }
 
-static inline int msgpack_vrefbuffer_write(void* data, const char* buf, unsigned int len)
+static inline int msgpack_vrefbuffer_write(void* data, const char* buf, size_t len)
 {
 	msgpack_vrefbuffer* vbuf = (msgpack_vrefbuffer*)data;
 
diff --git a/src/msgpack/vrefbuffer.hpp b/src/msgpack/vrefbuffer.hpp
index 3017eca1..2cf7f89c 100644
--- a/src/msgpack/vrefbuffer.hpp
+++ b/src/msgpack/vrefbuffer.hpp
@@ -40,7 +40,7 @@ public:
 	}
 
 public:
-	void write(const char* buf, unsigned int len)
+	void write(const char* buf, size_t len)
 	{
 		if(len < base::ref_size) {
 			append_copy(buf, len);
diff --git a/src/vrefbuffer.c b/src/vrefbuffer.c
index a27b138e..19c4cfc4 100644
--- a/src/vrefbuffer.c
+++ b/src/vrefbuffer.c
@@ -95,7 +95,7 @@ void msgpack_vrefbuffer_clear(msgpack_vrefbuffer* vbuf)
 }
 
 int msgpack_vrefbuffer_append_ref(msgpack_vrefbuffer* vbuf,
-		const char* buf, unsigned int len)
+		const char* buf, size_t len)
 {
 	if(vbuf->tail == vbuf->end) {
 		const size_t nused = vbuf->tail - vbuf->array;
@@ -120,7 +120,7 @@ int msgpack_vrefbuffer_append_ref(msgpack_vrefbuffer* vbuf,
 }
 
 int msgpack_vrefbuffer_append_copy(msgpack_vrefbuffer* vbuf,
-		const char* buf, unsigned int len)
+		const char* buf, size_t len)
 {
 	msgpack_vrefbuffer_inner_buffer* const ib = &vbuf->inner_buffer;