diff options
author | frsyuki <frsyuki@5a5092ae-2292-43ba-b2d5-dcab9c1a2731> | 2009-02-15 09:09:59 +0000 |
---|---|---|
committer | frsyuki <frsyuki@5a5092ae-2292-43ba-b2d5-dcab9c1a2731> | 2009-02-15 09:09:59 +0000 |
commit | 8be25a7f3216007dd3e9561076bd2e7cf3945b90 (patch) | |
tree | 71d341a5e1e7c3b5fb9292fa7e56b8a6e9fccee6 /cpp/unpack.cpp | |
parent | 33986868162e0c312fd9547e7c05199d684bd07a (diff) | |
download | msgpack-python-8be25a7f3216007dd3e9561076bd2e7cf3945b90.tar.gz |
unpacker::unpacker() accepts initial buffer size
git-svn-id: file:///Users/frsyuki/project/msgpack-git/svn/x@82 5a5092ae-2292-43ba-b2d5-dcab9c1a2731
Diffstat (limited to 'cpp/unpack.cpp')
-rw-r--r-- | cpp/unpack.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/cpp/unpack.cpp b/cpp/unpack.cpp index ea4d414..8edf407 100644 --- a/cpp/unpack.cpp +++ b/cpp/unpack.cpp @@ -178,13 +178,14 @@ private: }; -unpacker::unpacker() : +unpacker::unpacker(size_t initial_buffer_size) : m_buffer(NULL), m_used(0), m_free(0), m_off(0), m_zone(new zone()), - m_ctx(new context(&*m_zone)) + m_ctx(new context(&*m_zone)), + m_initial_buffer_size(initial_buffer_size) { } @@ -199,14 +200,14 @@ void unpacker::expand_buffer(size_t len) if(m_off == 0) { size_t next_size; if(m_used != 0) { next_size = (m_used + m_free) * 2; } - else { next_size = UNPACKER_INITIAL_BUFFER_SIZE; } + else { next_size = m_initial_buffer_size; } while(next_size < len + m_used) { next_size *= 2; } m_buffer = m_zone->realloc(m_buffer, next_size); m_free = next_size - m_used; } else { - size_t next_size = UNPACKER_INITIAL_BUFFER_SIZE; + size_t next_size = m_initial_buffer_size; while(next_size < len + m_used - m_off) { next_size *= 2; } char* tmp = m_zone->malloc(next_size); |