mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38: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
|
@ -44,7 +44,15 @@ public:
|
|||
|
||||
// Serialization.
|
||||
virtual void StartWrite();
|
||||
virtual uint32 EndWrite(char** data); // passes ownership
|
||||
|
||||
/**
|
||||
* Retrieves serialized data.
|
||||
* @param data A pointer that will be assigned to point at the internal
|
||||
* buffer containing serialized data. The memory should
|
||||
* be reclaimed using "free()".
|
||||
* @return The number of bytes in the buffer object assigned to \a data.
|
||||
*/
|
||||
virtual uint32 EndWrite(char** data);
|
||||
|
||||
virtual bool Write(int v, const char* tag) = 0;
|
||||
virtual bool Write(uint16 v, const char* tag) = 0;
|
||||
|
@ -74,6 +82,7 @@ protected:
|
|||
bool WriteData(const void* buf, size_t count);
|
||||
|
||||
static const uint32 INITIAL_SIZE = 65536;
|
||||
static const float GROWTH_FACTOR;
|
||||
char* output;
|
||||
uint32 output_size;
|
||||
uint32 output_pos;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue