binsert.c File Reference

#include "globals.h"
#include "macros.h"
#include "binsert.h"
#include <string.h>

Defines

Functions


Define Documentation

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

See also:
binsert_g

Referenced by binsert_g().


Function Documentation

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);

Parameters:
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)
Returns:
Address of the (new) element

References cl_malloc(), cl_realloc(), and REALLOC_THRESHOLD.

Referenced by ComputeGroupInternally().


Generated on Sun Feb 28 18:08:03 2010 for CWB by  doxygen 1.6.1