Dillo v3.1.1-111-gd4f56d0d
Loading...
Searching...
No Matches
list.h File Reference

Fast list methods. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define a_List_resize(list, num_items, alloc_step)
 Make sure there's space for 'num_items' items within the list.
 
#define a_List_add(list, num_items, alloc_step)    a_List_resize(list,num_items,alloc_step)
 Make sure there's space for one more item within the list.
 
#define a_List_remove(list, item, num_items)
 Quickly remove an item from the list ==> We preserve relative position, but not the element index <==.
 

Detailed Description

Fast list methods.

Feb 2000 –Jcid

Definition in file list.h.

Macro Definition Documentation

◆ a_List_add

#define a_List_add (   list,
  num_items,
  alloc_step 
)     a_List_resize(list,num_items,alloc_step)

Make sure there's space for one more item within the list.

Definition at line 30 of file list.h.

◆ a_List_remove

#define a_List_remove (   list,
  item,
  num_items 
)
Value:
if (list && item < num_items) { \
list[item] = list[--num_items]; \
}

Quickly remove an item from the list ==> We preserve relative position, but not the element index <==.

Definition at line 38 of file list.h.

◆ a_List_resize

#define a_List_resize (   list,
  num_items,
  alloc_step 
)
Value:
if (!list) { \
list = dMalloc(alloc_step * sizeof(*list)); \
} \
if (num_items >= alloc_step){ \
while ( num_items >= alloc_step ) \
alloc_step <<= 1; \
list = dRealloc(list, alloc_step * sizeof(*list)); \
}
void * dMalloc(size_t size)
Definition dlib.c:45
void * dRealloc(void *mem, size_t size)
Definition dlib.c:53

Make sure there's space for 'num_items' items within the list.

(First, allocate an 'alloc_step' sized chunk, after that, double the list size –to make it faster)

Definition at line 16 of file list.h.