GATE
|
C-string buffer class. More...
#include <strings.h>
Data Fields | |
gate_char8_t const * | str |
gate_size_t | length |
gate_char8_t * | heap_buffer |
gate_char8_t | local_buffer [GATE_DEFAULT_LINE_LENGTH] |
C-string buffer class.
GATE strings need not to be NUL-terminated, but many C APIs require this convention. A C-string buffer takes a string pointer, and check it for NUL-termination. If it's NUL-terminated, it takes it as it is. Otherwise it checks the length and tries to copy it into a local buffer. If the local buffer is not big enough, a heap allocation is done to copy the string into it. At the end we get a string pointer that points to a NUL-terminated string.
gate_char8_t const* str |
actual pointer to NUL-terminated string
gate_size_t length |
length of NUL-terminated string (not counting the NUL char)
gate_char8_t* heap_buffer |
optional point to heap-allocated string (for deletion)
gate_char8_t local_buffer[GATE_DEFAULT_LINE_LENGTH] |
< optional local buffer for NUL-terminated string