picotm  0.4.0
Typedefs | Functions
picotm-lib-tab.h File Reference
#include <stddef.h>
#include "compiler.h"
Include dependency graph for picotm-lib-tab.h:

Typedefs

typedef size_t(* picotm_tabwalk_1_function) (void *data0, struct picotm_error *error)
 
typedef size_t(* picotm_tabwalk_2_function) (void *data0, void *data1, struct picotm_error *error)
 
typedef size_t(* picotm_tabwalk_3_function) (void *data0, void *data1, void *data2, struct picotm_error *error)
 
typedef int(* picotm_tab_compare_function) (const void *data0, const void *data1)
 

Functions

PICOTM_NOTHROW void * picotm_tabresize (void *base, size_t nelems, size_t newnelems, size_t siz, struct picotm_error *error)
 
PICOTM_NOTHROW void picotm_tabfree (void *base)
 
PICOTM_NOTHROW size_t picotm_tabwalk_1 (void *base, size_t nelems, size_t siz, picotm_tabwalk_1_function walk, struct picotm_error *error)
 
PICOTM_NOTHROW size_t picotm_tabwalk_2 (void *base, size_t nelems, size_t siz, picotm_tabwalk_2_function walk, void *data, struct picotm_error *error)
 
PICOTM_NOTHROW size_t picotm_tabwalk_3 (void *base, size_t nelems, size_t siz, picotm_tabwalk_3_function walk, void *data1, void *data2, struct picotm_error *error)
 
PICOTM_NOTHROW size_t picotm_tabrwalk_1 (void *base, size_t nelems, size_t siz, picotm_tabwalk_1_function walk, struct picotm_error *error)
 
PICOTM_NOTHROW size_t picotm_tabrwalk_2 (void *base, size_t nelems, size_t siz, picotm_tabwalk_2_function walk, void *data, struct picotm_error *error)
 
PICOTM_NOTHROW size_t picotm_tabuniq (void *base, size_t nelems, size_t siz, picotm_tab_compare_function compare)
 

Typedef Documentation

◆ picotm_tab_compare_function

typedef int(* picotm_tab_compare_function) (const void *data0, const void *data1)

Invoked by table functions for comparing two elements.

Parameters
data0A table element.
data1A table element.
Returns
A value less, equal, or greater to zero if data0 is less, equal, or greatet than data1.

◆ picotm_tabwalk_1_function

typedef size_t(* picotm_tabwalk_1_function) (void *data0, struct picotm_error *error)

Invoked by table functions when walking over the elements of a table.

Parameters
data0The table element.
[out]errorReturns an error from the module.
Returns
The number of element to advance.

◆ picotm_tabwalk_2_function

typedef size_t(* picotm_tabwalk_2_function) (void *data0, void *data1, struct picotm_error *error)

Invoked by table functions when walking over the elements of a table.

Parameters
data0The table element.
data1An additional argument.
[out]errorReturns an error from the module.
Returns
The number of element to advance.

◆ picotm_tabwalk_3_function

typedef size_t(* picotm_tabwalk_3_function) (void *data0, void *data1, void *data2, struct picotm_error *error)

Invoked by table functions when walking over the elements of a table.

Parameters
data0The table element.
data1An additional argument.
data2An additional argument.
[out]errorReturns an error from the module.
Returns
The number of element to advance.

Function Documentation

◆ picotm_tabfree()

PICOTM_NOTHROW void picotm_tabfree ( void *  base)

Free table memory.

Parameters
baseA pointer to the table's first element.

◆ picotm_tabresize()

PICOTM_NOTHROW void* picotm_tabresize ( void *  base,
size_t  nelems,
size_t  newnelems,
size_t  siz,
struct picotm_error error 
)

Allocate or resize table.

Parameters
baseA pointer to the table's first element.
nelemsThe number of elements in the table.
newnelemsThe new number of elements in the table.
sizThe number of bytes per element.
[out]errorReturns an error from the module.
Returns
A pointer to the resized table on success, or NULL otherwise.

◆ picotm_tabrwalk_1()

PICOTM_NOTHROW size_t picotm_tabrwalk_1 ( void *  base,
size_t  nelems,
size_t  siz,
picotm_tabwalk_1_function  walk,
struct picotm_error error 
)

Walk over table in reversed order.

Parameters
baseA pointer to the table's first element.
nelemsThe number of elements in the table.
sizThe number of bytes per element.
walkThe call-back function.
[out]errorReturns an error from the module.
Returns
The number of walked elements.

◆ picotm_tabrwalk_2()

PICOTM_NOTHROW size_t picotm_tabrwalk_2 ( void *  base,
size_t  nelems,
size_t  siz,
picotm_tabwalk_2_function  walk,
void *  data,
struct picotm_error error 
)

Walk over table in reversed order.

Parameters
baseA pointer to the table's first element.
nelemsThe number of elements in the table.
sizThe number of bytes per element.
walkThe call-back function.
dataAn additional second argument to the call-back function.
[out]errorReturns an error from the module.
Returns
The number of walked elements.

◆ picotm_tabuniq()

PICOTM_NOTHROW size_t picotm_tabuniq ( void *  base,
size_t  nelems,
size_t  siz,
picotm_tab_compare_function  compare 
)

Filters out duplicate elements

Parameters
baseA pointer to the table's first element.
nelemsThe number of elements in the table.
sizThe number of bytes per element.
compareThe call-back function for comparing elements.
Returns
The new number of elements in the table.

◆ picotm_tabwalk_1()

PICOTM_NOTHROW size_t picotm_tabwalk_1 ( void *  base,
size_t  nelems,
size_t  siz,
picotm_tabwalk_1_function  walk,
struct picotm_error error 
)

Walk over table elements.

Parameters
baseA pointer to the table's first element.
nelemsThe number of elements in the table.
sizThe number of bytes per element.
walkThe call-back function.
[out]errorReturns an error from the module.
Returns
The number of walked elements.

◆ picotm_tabwalk_2()

PICOTM_NOTHROW size_t picotm_tabwalk_2 ( void *  base,
size_t  nelems,
size_t  siz,
picotm_tabwalk_2_function  walk,
void *  data,
struct picotm_error error 
)

Walk over table elements.

Parameters
baseA pointer to the table's first element.
nelemsThe number of elements in the table.
sizThe number of bytes per element.
walkThe call-back function.
dataAn additional second argument to the call-back function.
[out]errorReturns an error from the module.
Returns
The number of walked elements.

◆ picotm_tabwalk_3()

PICOTM_NOTHROW size_t picotm_tabwalk_3 ( void *  base,
size_t  nelems,
size_t  siz,
picotm_tabwalk_3_function  walk,
void *  data1,
void *  data2,
struct picotm_error error 
)

Walk over table elements.

Parameters
baseA pointer to the table's first element.
nelemsThe number of elements in the table.
sizThe number of bytes per element.
walkThe call-back function.
data1An additional second argument to the call-back function.
data2An additional third argument to the call-back function.
[out]errorReturns an error from the module.
Returns
The number of walked elements.