NAME
stralloc_ready_tuned, stralloc_readyplus_tuned, stralloc_ready, stralloc_readyplus, stralloc_free, stralloc_shrink - allocate and free memory associated with a stralloc
SYNOPSIS
#include <limb/stralloc.h>
int stralloc_ready_tuned(stralloc *sa, size_t len, size_t base, size_t a, size_t b) int stralloc_readyplus_tuned(stralloc *sa, size_t len, size_t base, size_t a, size_t b) int stralloc_ready(stralloc *sa, size_t len) int stralloc_readyplus(stralloc *sa, size_t len) void stralloc_free(stralloc *sa) int stralloc_shrink(stralloc *sa)
DESCRIPTION
The stralloc_ready
() macro ensure that at least len
bytes are allocated in
stralloc sa
, reallocating memory if needed. This does not mean as much is
available, as there might be data in use already.
The stralloc_readyplus
() macro ensure that at least len
bytes are available
in stralloc sa
, reallocating memory if needed. Available here means space
that is allocated but not yet in use, making this the most commonly used way to
prepare a stralloc before writing data into it.
The stralloc_ready_tuned
() is similar to stralloc_ready
() but with more
fine-tuning settings.
The stralloc_readyplus_tuned
() is similar to stralloc_ready_tuned
() but for
adding len
bytes to the currently in-use size.
Note that this is only needed when writing into the stralloc directly, as all functions of the stralloc API (e.g. stralloc_catb(3)) handles that automatically.
The stralloc_shrink
() function will ensure that the allocated memory is only
as large as is in use in stralloc sa
.
The stralloc_free
() function will free all memory associated with the stralloc
sa
.
RETURN VALUE
These functions (except for stralloc_free
()) return 1 on success. Otherwise
they return 0 and set errno
to indicate the error.
ERRORS
These functions (except for stralloc_free
()) may fail if :
ENOMEM
Out of memory.
The stralloc_ready_tuned
(), stralloc_ready
(), stralloc_readyplus_tuned
()
and stralloc_readyplus
() functions may also fail if :
EINVAL
The base
is zero.
ERANGE
Overflow.