Welcome to little lamb

Code » limb » release » tree

[release] / src / doc / stralloc.h / stralloc.h.0.md

% limb manual
% stralloc.h(0)
% limb 0.1.0
% 2023-07-24

# NAME

stralloc.h - heap memory management

# SYNOPSIS

    #include <limb/stralloc.h>

# DESCRIPTION

This header defines functions to work heap-allocated memory.

<inc skalibs.md>

## 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 :

: [stralloc_ready_tuned](3)
:: Ensure there's enough space in a *stralloc*.

: [stralloc_readyplus_tuned](3)
:: Ensure there's enough extra space in a *stralloc*.

: [stralloc_ready](3)
:: Ensure there's enough space in a *stralloc*.

: [stralloc_readyplus](3)
:: Ensure there's enough extra space in a *stralloc*.


: [stralloc_free](3)
:: Free memory associated with a *stralloc*.

: [stralloc_shrink](3)
:: Reduce memory usage to what's used.


: [stralloc_copyb](3)
:: Copy data into a *stralloc*.

: [stralloc_copy](3)
:: Copy content of a *stralloc* into another one.

: [stralloc_copys](3)
:: Copy a string (excluding its NUL-terminating byte) into a *stralloc*.

: [stralloc_copys0](3)
:: Copy a string and its NUL-terminating byte into a *stralloc*.

: [stralloc_catv](3)
:: Append data from an array of vectors into a *stralloc*.

: [stralloc_catb](3)
:: Append data into a *stralloc*.

: [stralloc_cat](3)
:: Append the content of a *stralloc* into another one.

: [stralloc_cats](3)
:: Append a string (excluding its NUL-terminating byte) into a *stralloc*.

: [stralloc_cats0](3)
:: Append a string and its NUL-terminating byte into a *stralloc*.

: [stralloc_0](3)]
:: Append a NUL byte into a *stralloc*.

: [stralloc_append](3)
:: Append a character into a *stralloc*.


: [stralloc_insertb](3)
:: Insert data into a *stralloc* at a specific offset.

: [stralloc_insert](3)
:: Insert the content of a *stralloc* into another one at a specific offset.

: [stralloc_inserts](3)
:: Insert a string (excluding its NUL-terminating byte) into a *stralloc* at a
:: specific offset.

: [stralloc_inserts0](3)
:: Insert a string and its NUL-terminating byte into a *stralloc* at a specific
:: offset.


: [stralloc_remove](3)
:: Remove data from a *stralloc*.


: [stralloc_reverse](3)
:: Reverse the content of a *stralloc*.

: [stralloc_reverse_blocks](3)
:: Reverse the content of a *stralloc* divided into blocks a given length.