mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-02-07 02:09:59 +00:00
lang/c/msgpack: C++ binding: support non-MessagePack message that follows after MessagePack message
git-svn-id: file:///Users/frsyuki/project/msgpack-git/svn/x@56 5a5092ae-2292-43ba-b2d5-dcab9c1a2731
This commit is contained in:
parent
990ac38ccd
commit
7e6b55a718
3 changed files with 64 additions and 7 deletions
|
|
@ -82,7 +82,6 @@ void unpacker::expand_buffer(size_t len)
|
|||
while(next_size < len + m_used) { next_size *= 2; }
|
||||
|
||||
// FIXME realloc?
|
||||
|
||||
void* tmp = malloc(next_size);
|
||||
if(!tmp) { throw std::bad_alloc(); }
|
||||
memcpy(tmp, m_buffer, m_used);
|
||||
|
|
@ -121,15 +120,16 @@ bool unpacker::execute()
|
|||
} else if(ret == 0) {
|
||||
return false;
|
||||
} else {
|
||||
expand_buffer(0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
zone* unpacker::release_zone()
|
||||
{
|
||||
zone* nz = new zone();
|
||||
zone* z = m_zone;
|
||||
m_zone = NULL;
|
||||
m_zone = new zone();
|
||||
m_zone = nz;
|
||||
m_ctx->user(m_zone);
|
||||
return z;
|
||||
}
|
||||
|
|
@ -141,12 +141,12 @@ object unpacker::data()
|
|||
|
||||
void unpacker::reset()
|
||||
{
|
||||
if(m_off != 0) { expand_buffer(0); }
|
||||
if(!m_zone->empty()) {
|
||||
delete m_zone;
|
||||
m_zone = NULL;
|
||||
m_zone = new zone();
|
||||
}
|
||||
expand_buffer(0);
|
||||
m_ctx->reset();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue