#include "globals.h"
#include "macros.h"
#include "binsert.h"
#include <string.h>
#define REALLOC_THRESHOLD 16 |
Memory reallocation threshold for binserting.
This threshold applies to "tables" manipulated with binsert_g(). When the memory for these "tables" is allocated/reallocated, this is done in increments of REALLOC_THRESHOLD elements. So in theory reallocation will not be need more than once every REALLOC_THRESHOLD times the binsert_g() function is called.
Referenced by binsert_g().
void* binsert_g | ( | const void * | key, | |
void ** | base, | |||
size_t * | nel, | |||
size_t | size, | |||
int(*)(const void *, const void *) | compar | |||
) |
Inserts an element into the table of elements at base.
If base is NULL, a new "table" is created, and a single element copied into it.
The memory of this table of elements will be reallocated if necessary.
How to call this function:
(void) binsert_g(&nr, (void **)&Table, &Nr_Elements, sizeof(int), intcompare);
key | Pointer to the element to add | |
base | Location of pointer to the table | |
nel | Number of elements (will be incremented by this function) | |
size | The size of each element in the table. | |
compar | Comparison function (returns int, takes two pointers as arguments) |
References cl_malloc(), cl_realloc(), and REALLOC_THRESHOLD.
Referenced by ComputeGroupInternally().