NAME
stralloc.h - heap memory management
SYNOPSIS
#include <limb/stralloc.h>
DESCRIPTION
This header defines functions to work heap-allocated memory.
This header is a complement to skalibs' own header, intended to be used as a "replacement". However, instead of re-inventing the wheel, it depends/includes skalibs' header, and some of the functions below are actually implemented in skalibs, or macros to such functions.
Structures
The following structures are defined :
struct stralloc
A structure representing headp-allocated data, defined as such :
struct stralloc_s { char *s; size_t len; size_t a; }
Only members s
- a pointer to the data, that may change over time as
reallocation are needed - and len
- the length is data currently in use -
should be accessed. The member a
- currently allocated size - might be
used in read-only fashion.
Types
The following types are defined :
stralloc
A struct stralloc_s
Objects
The following objects are defined :
stralloc_zero
An empty stralloc, which can be used for initialization.
Macros
The following macros are defined :
STRALLOC_ZERO
Value to initialize a stack-allocated stralloc.
Functions
The following functions/macros are defined :
Ensure there's enough space in a stralloc.
Ensure there's enough extra space in a stralloc.
Ensure there's enough space in a stralloc.
Ensure there's enough extra space in a stralloc.
Free memory associated with a stralloc.
Reduce memory usage to what's used.
Copy data into a stralloc.
Copy content of a stralloc into another one.
Copy a string (excluding its NUL-terminating byte) into a stralloc.
Copy a string and its NUL-terminating byte into a stralloc.
Append data from an array of vectors into a stralloc.
Append data into a stralloc.
Append the content of a stralloc into another one.
Append a string (excluding its NUL-terminating byte) into a stralloc.
Append a string and its NUL-terminating byte into a stralloc.
Append a NUL byte into a stralloc.
Append a character into a stralloc.
Insert data into a stralloc at a specific offset.
Insert the content of a stralloc into another one at a specific offset.
Insert a string (excluding its NUL-terminating byte) into a stralloc at a specific offset.
Insert a string and its NUL-terminating byte into a stralloc at a specific offset.
Remove data from a stralloc.
Reverse the content of a stralloc.
Reverse the content of a stralloc divided into blocks a given length.