FreeBASIC  0.91.0
list.c File Reference
#include "fb.h"
Include dependency graph for list.c:

Go to the source code of this file.

Functions

void fb_hListInit (FB_LIST *list, void *table, size_t elem_size, size_t size)
 Initializes a list. More...
 
FB_LISTELEMfb_hListAllocElem (FB_LIST *list)
 Allocate a new list element. More...
 
void fb_hListFreeElem (FB_LIST *list, FB_LISTELEM *elem)
 Free a list element. More...
 

Function Documentation

FB_LISTELEM* fb_hListAllocElem ( FB_LIST list)

Allocate a new list element.

This function gets an element from the list of free elements ( struct _FB_LIST::fhead ) and adds to the tail. It also increases the number of used elements ( struct _FB_LIST::cnt ).

Parameters
listPointer to the list structure.
Returns
A new element.

Definition at line 47 of file list.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void fb_hListFreeElem ( FB_LIST list,
FB_LISTELEM elem 
)

Free a list element.

This function frees a list element by removing it from the list of used elements and adding it to the list of free elements ( struct _FB_LIST::fhead ). It also decreses the number of used elements ( struct _FB_LIST::cnt ).

Parameters
listPointer to the list structure.
elemList element to add to the list of free elements.

Definition at line 74 of file list.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void fb_hListInit ( FB_LIST list,
void *  table,
size_t  elem_size,
size_t  size 
)

Initializes a list.

This list implementation is based on a static array.

Parameters
listPointer to list structure to initialize.
tablePointer to the pool of available list elements.
elem_sizeSize of elements in the array.
sizeNumber of elements in the array.

Definition at line 14 of file list.c.

Here is the call graph for this function:

Here is the caller graph for this function: