MGE General C Library - API Documentation v1.8.0
Library of general C functions.
|
Header file for buffer processing. More...
Go to the source code of this file.
Data Structures | |
struct | mgebuffer |
A buffer object. More... | |
Macros | |
#define | MGEBUFFER_INIT |
A buffer object initialisation macro. More... | |
Functions | |
struct mgebuffer * | concat_buf (const char *s_buf, const size_t s_buf_os, struct mgebuffer *m_buf) |
Concatenate the used portion of a flat buffer into a buffer object. More... | |
struct mgebuffer * | trim_buf (struct mgebuffer *msg_buf) |
Remove processed data from a buffer object if deemed necessary. More... | |
void | print_buf (struct mgebuffer *m_buf) |
Print a buffer object to stdout, (for debugging). More... | |
void | print_def_buf_values (void) |
Print the key default values to stdout, (for debugging). More... | |
Header file for buffer processing.
All buffer manipulation related information.
Released under the GPLv3 only.
SPDX-License-Identifier: GPL-3.0-only
#define MGEBUFFER_INIT |
A buffer object initialisation macro.
struct mgebuffer * concat_buf | ( | const char * | s_buf, |
const size_t | s_buf_os, | ||
struct mgebuffer * | m_buf | ||
) |
Concatenate the used portion of a flat buffer into a buffer object.
On failure NULL is returned, the function arguments are unchanged and mge_errno will be set.
s_buf | Source buffer. |
s_buf_os | Offset into source buffer ie extent of used portion. |
m_buf | The buffer object to use. |
void print_buf | ( | struct mgebuffer * | m_buf | ) |
Print a buffer object to stdout, (for debugging).
m_buf | Buffer to print. |
void print_def_buf_values | ( | void | ) |
Print the key default values to stdout, (for debugging).
Remove processed data from a buffer object if deemed necessary.
Re-sizing the buffer every time this function is called would not be efficient. So, the function first tests whether the buffer has a defined multiple of the default buffer size (BUF_UNUSED_DEF_SIZE_MULT) free, and if so shrinks the buffer and relocates valid data to the start of the buffer. If that test does not result in action, the second test determines if the percentage of unreachable portion of the buffer to the size of the buffer exceeds a defined value (BUF_MAX_UNREACH_PERCENT), and if so, it relocates data to the start of the buffer. On failure NULL is returned, the function argument is unchanged and mge_errno will be set.
m_buf | Pointer to the buffer object to process. |