FreeWRL/FreeX3D
3.0.0
|
A generic buffer class. More...
#include <cson_amalgamation_core.h>
Data Fields | |
cson_size_t | capacity |
The number of bytes allocated for this object. More... | |
cson_size_t | used |
The number of bytes "used" by this object. More... | |
cson_size_t | timesExpanded |
This is a debugging/metric-counting value intended to help certain malloc()-conscious clients tweak their memory reservation sizes. More... | |
unsigned char * | mem |
The memory allocated for and owned by this buffer. More... | |
A generic buffer class.
They can be used like this:
To take over ownership of a buffer's memory:
The memory now belongs to the caller and must eventually be free()d.
Definition at line 1826 of file cson_amalgamation_core.h.
cson_size_t cson_buffer::capacity |
The number of bytes allocated for this object.
Use cson_buffer_reserve() to change its value.
Definition at line 1832 of file cson_amalgamation_core.h.
unsigned char* cson_buffer::mem |
The memory allocated for and owned by this buffer.
Use cson_buffer_reserve() to change its size or free it. To take over ownership, do:
(You might also need to store buf.used and buf.capacity, depending on what you want to do with the memory.)
When doing so, the memory must eventually be passed to free() to deallocate it.
Definition at line 1868 of file cson_amalgamation_core.h.
cson_size_t cson_buffer::timesExpanded |
This is a debugging/metric-counting value intended to help certain malloc()-conscious clients tweak their memory reservation sizes.
Each time cson_buffer_reserve() expands the buffer, it increments this value by 1.
Definition at line 1850 of file cson_amalgamation_core.h.
cson_size_t cson_buffer::used |
The number of bytes "used" by this object.
It is not needed for all use cases, and management of this value (if needed) is up to the client. The cson_buffer public API does not use this member. The intention is that this can be used to track the length of strings which are allocated via cson_buffer, since they need an explicit length and/or null terminator.
Definition at line 1841 of file cson_amalgamation_core.h.