mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 01:58:20 +00:00
Refactor SerializationFormat::EndWrite and ChunkedIO::Chunk mem mgmt.
SerializationFormat::EndWrite now transfers ownership of the buffer to the caller instead of doing a memcpy. ChunkedIO::Chunk is no longer a POD type, hopefully the ctor/dtor make it easier to manage its associated memory. It also now tracks how to deallocate its buffer (i.e. delete vs. free).
This commit is contained in:
parent
07a4a8d147
commit
70131b5c84
9 changed files with 87 additions and 77 deletions
|
@ -81,6 +81,7 @@ bool Serializer::EndSerialization(SerialInfo* info)
|
|||
|
||||
ChunkedIO::Chunk* chunk = new ChunkedIO::Chunk;
|
||||
chunk->len = format->EndWrite(&chunk->data);
|
||||
chunk->free_func = ChunkedIO::Chunk::free_func_free;
|
||||
|
||||
if ( ! io->Write(chunk) )
|
||||
{
|
||||
|
@ -282,7 +283,6 @@ int Serializer::Unserialize(UnserialInfo* info, bool block)
|
|||
|
||||
if ( ! info->chunk )
|
||||
{ // only delete if we allocated it ourselves
|
||||
delete [] chunk->data;
|
||||
delete chunk;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue