7 #include <cfe/cfe_value.h> 279 #define INIT_TABLE_TYPE_DEF(NAME) \ 280 table_t * NAME##_table_init(void); \ 281 table_t * NAME##_table_init_with_allocator(table_malloc_func_t malloc_func, table_realloc_func_t realloc_func, table_free_func_t free_func); 288 #define ADD_FIELD(ID, FUNC) get_functions[ID] = (table_get_function_t)(FUNC); 296 #define INIT_TABLE_TYPE(NAME, TYPE) INIT_TABLE_TYPE_WITH_FIELDS(NAME, TYPE, 0, (void)0;) 305 #define INIT_TABLE_TYPE_WITH_FIELDS(NAME, TYPE, N_F, FIELDS) \ 306 table_t * NAME##_table_init(void) \ 308 return NAME##_table_init_with_allocator(table_malloc_wrapper, table_realloc_wrapper, table_free_wrapper); \ 310 table_t * NAME##_table_init_with_allocator(table_malloc_func_t malloc_func, table_realloc_func_t realloc_func, table_free_func_t free_func) \ 312 table_t *t = table_new(#NAME, sizeof(TYPE), NAME##_table_init, NAME##_table_compare, NAME##_table_get_record, NAME##_table_entry_free, malloc_func, realloc_func, free_func); \ 313 table_get_function_t *get_functions = (table_get_function_t *)malloc(N_F * sizeof(table_get_function_t)); \ 315 table_set_get_functions(t, get_functions); \ 326 #define TABLE_STORE_START(TABLE_TYPE, TABLE, P) \ 327 P = table_store_start(#TABLE_TYPE, (table_t *)TABLE, (rec_t)P); \ 328 if(P == RECORD_INVALID) \ 330 return RECORD_INVALID; \ 339 #define TABLE_STORE_RETURN(TABLE, P, PTR) return table_store_return((table_t *)TABLE, (rec_t)P, (void *)PTR); int8_t table_sort(table_t *t)
rec_t table_get_num_records(const table_t *t)
void table_set_get_functions(table_t *table, table_get_function_t *array)
int table_entry_free_move_by_ptr(table_t *t, void *ptr)
void table_set_inform_add(table_t *table, table_alter_t add)
int table_entry_free_block_move(table_t *t, rec_t first, rec_t last)
void table_set_inform_user_data(table_t *table, void *user_data)
int(* table_compare_t)(void *, void *)
void(* table_alter_t)(const table_t *, rec_t, void *user_data)
cfe_value_t *(* table_get_function_t)(const table_t *, void *)
table_t *(* table_init_t)(void)
Type specific initialize function.
int table_entry_free_move(table_t *t, rec_t i)
int table_free(table_t *t)
void * table_get_record(const table_t *table, rec_t n)
void * table_realloc_wrapper(const table_t *t, void *ptr, size_t size)
void(* table_free_func_t)(const table_t *, void *)
int table_entry_free(table_t *t, rec_t i)
char * libcfe_tables_version(void)
cfe_value_t * table_get_value_by_number(const table_t *table, int field, rec_t n)
void * table_malloc_wrapper(const table_t *t, size_t size)
void table_record_removed(const table_t *table, rec_t pos)
int8_t table_check_type(const table_t *t, const char *type)
void * table_allocate_record_with_size(const table_t *table, size_t size)
rec_t table_store_return(table_t *t, rec_t pos, void *ptr)
void(* table_free_entry_t)(void *)
Type specific function to free the memory used inside a record.
void table_set_inform_change(table_t *table, table_alter_t change)
void *(* table_malloc_func_t)(const table_t *, size_t)
struct _table table_t
Table type.
void table_free_wrapper(const table_t *t, void *)
int8_t table_validate(const table_t *t, rec_t i, const char *type)
int8_t table_diff(const table_t *t1, table_t *t2)
rec_t table_get_record_number_by_pointer(const table_t *t, void *r)
void table_set_inform_remove(table_t *table, table_alter_t remove)
int8_t table_unique(table_t *t)
void table_entry_move(table_t *t, rec_t from, rec_t to)
uint32_t rec_t
Type to identify a record number.
void table_record_inserted(const table_t *table, rec_t pos)
table_t * table_new(const char *name, size_t soe, table_init_t init_func, table_compare_t comp_func, table_get_record_number_by_pointer_t get_record_func, table_free_entry_t entry_free_func, table_malloc_func_t malloc_func, table_realloc_func_t realloc_func, table_free_func_t free_func)
void table_entry_swap(table_t *t, rec_t i, rec_t j)
void table_record_changed(const table_t *table, rec_t pos)
void * table_allocate_record(const table_t *table)
rec_t(* table_get_record_number_by_pointer_t)(const table_t *, void *)
Type specific function to get the record number of a give record.
rec_t table_store_start(const char *type, table_t *t, rec_t pos)
void *(* table_realloc_func_t)(const table_t *, void *, size_t)
cfe_value_t * table_get_value_by_record(const table_t *table, int field, void *record)