MuPDF X.Y.Z

fitz/list.h

Index

macro

function

List

These functions implement generic lists. They rely on 3 variables, sharing a common root. The trick that these macros rely on, is that the naming of these different variables is standard.

int foo_cap; int foo_len; <some type *>foo

These can be local variables, or members of a struct.

In all the functions below, we pass foo (or ‘bar->foo’, or ‘bar.foo’ etc), and foo_cap and foo_len are found by C preprocessor extending the name of the list.

macro fz_list

#define fz_list(TYPE, NAME)

A macro to prettily instantiate a list.

Declare a list of entries of type ‘TYPE’ referred to by ‘NAME’.

macro fz_push_list

#define fz_push_list(CTX, ELEM)

Push a new element onto a given list.

Returns a pointer to the new element.

macro fz_push_list_init

#define fz_push_list_init(CTX, ELEM, INITIAL)

Push a new element onto a list, with a suggested initial size for the list.

Returns a pointer to the new element.

macro fz_extend_list

#define fz_extend_list(CTX, ELEM, N)

Push n new elements onto a list.

Returns a pointer to the first new element.

macro fz_extend_list_init

#define fz_extend_list_init(CTX, ELEM, N, INITIAL)

Push n new elements onto a list, with a suggested initial size.

Returns a pointer to the first new element.

macro fz_extend_list_tight

#define fz_extend_list_tight(CTX, ELEM, N)

Push n new elements onto a list, never growing the list further than it needs to be.

Returns a pointer to the first new element.

macro fz_trim_list

#define fz_trim_list(CTX, ELEM)

Trim the storage for a list to remove any excess.

function fz_push_list_imp

void *
fz_push_list_imp (
        fz_context *ctx,
        void **list,
        int *list_len,
        int *list_cap,
        size_t z,
        int initial
)

Functions used to implement the above macros.

function fz_extend_list_imp

void *
fz_extend_list_imp (
        fz_context *ctx,
        void **list,
        int *list_len,
        int *list_cap,
        size_t z,
        int n,
        int initial
)

function fz_extend_list_tight_imp

void *
fz_extend_list_tight_imp (
        fz_context *ctx,
        void **list,
        int *list_len,
        int *list_cap,
        size_t z,
        int n
)

function fz_trim_list_imp

void
fz_trim_list_imp (
        fz_context *ctx,
        void **list,
        int list_len,
        int *list_cap,
        size_t z
)