dillo  3.0.5
About: dillo is a small, fast, extensible Web browser particularly suitable for older or smaller computers and embedded systems (but only limited or no support for frames, CSS, JavaScript, Java).
  Fossies Dox: dillo-3.0.5.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

list.h
Go to the documentation of this file.
1 /*
2  * Fast list methods
3  * Feb 2000 --Jcid
4  *
5  */
6 
7 #ifndef __LIST_H__
8 #define __LIST_H__
9 
10 /*
11  * a_List_resize()
12  *
13  * Make sure there's space for 'num_items' items within the list
14  * (First, allocate an 'alloc_step' sized chunk, after that, double the
15  * list size --to make it faster)
16  */
17 #define a_List_resize(list,num_items,alloc_step) \
18  if (!list) { \
19  list = dMalloc(alloc_step * sizeof(*list)); \
20  } \
21  if (num_items >= alloc_step){ \
22  while ( num_items >= alloc_step ) \
23  alloc_step <<= 1; \
24  list = dRealloc(list, alloc_step * sizeof(*list)); \
25  }
26 
27 
28 /*
29  * a_List_add()
30  *
31  * Make sure there's space for one more item within the list.
32  */
33 #define a_List_add(list,num_items,alloc_step) \
34  a_List_resize(list,num_items,alloc_step)
35 
36 
37 /*
38  * a_List_remove()
39  *
40  * Quickly remove an item from the list
41  * ==> We preserve relative position, but not the element index <==
42  */
43 #define a_List_remove(list, item, num_items) \
44  if (list && item < num_items) { \
45  list[item] = list[--num_items]; \
46  }
47 
48 
49 #endif /* __LIST_H__ */