FreeBASIC  0.91.0
listdyn.c
Go to the documentation of this file.
1 /* generic internal dynamic lists */
2 
3 #include "fb.h"
4 
13 {
14  memset(list, 0, sizeof(FB_LIST));
15 }
16 
26 {
27  if( list->tail != NULL )
28  list->tail->next = elem;
29  else
30  list->head = elem;
31 
32  elem->prev = list->tail;
33  elem->next = NULL;
34 
35  list->tail = elem;
36 
37  ++list->cnt;
38 }
39 
49 {
50  /* del from used list */
51  if( elem->prev != NULL )
52  elem->prev->next = elem->next;
53  else
54  list->head = elem->next;
55 
56  if( elem->next != NULL )
57  elem->next->prev = elem->prev;
58  else
59  list->tail = elem->prev;
60 
61  /* reset element pointers */
62  elem->prev = elem->next = NULL;
63 
64  /* don't forget to change the number of elements in the list */
65  --list->cnt;
66 }