Inserting VZGOT development tree within GIT
[safe/jmp/vzgot] / lib / utlvec.h
1 /************************************************/
2 /*                                              */
3 /*      Copyright:                              */
4 /*       Jean-Marc Pigeon <jmp@safe.ca>  2009   */
5 /*                                              */
6 /************************************************/
7 /* This program is free software; you can       */
8 /* redistribute it and/or modify it under the   */
9 /* terms of the GNU General Public License as   */
10 /* published by the Free Software Foundation    */
11 /* version 2 of the License                     */
12 /*                                              */
13 /* This program is distributed in the hope that */
14 /* it will be useful, but WITHOUT ANY WARRANTY; */
15 /* without even the implied warranty of         */
16 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR  */
17 /* PURPOSE.  See the GNU General Public License */
18 /* for more details.                            */
19 /*                                              */
20 /* You should have received a copy of the GNU   */
21 /* General Public License along with this       */
22 /* program; if not, write to the Free Software  */
23 /* Foundation, Inc., 51 Franklin Street,        */
24 /* Fifth Floor, Boston, MA  02110-1301, USA.    */
25 /************************************************/
26 /*                                              */
27 /*      Define utility level procedure to manage*/
28 /*      dynamic memory list                     */
29 /*                                              */
30 /************************************************/
31 #ifndef UTLVEC
32 #define UTLVEC
33 #include        <stdlib.h>
34
35 #define VECFREE (void *(*)(void *))free
36
37
38 /*Vector list definition                        */
39 /*Doubly-circularly-linked lists                */
40 typedef struct LIST VECLST;
41 typedef struct LIST {
42         void *payload;  /*payload               */
43         VECLST *prv;    /*previous node         */
44         VECLST *nxt;    /*next node             */
45         }VECTOR;
46
47 typedef struct          {
48         u_int numvec;   /*number of vector      */
49         VECLST *vcl;    /*vector list           */
50         }VPTR;
51
52 extern VPTR *vec_addveclst(VPTR *vptr,void *payload);
53 extern int vec_rmveclst(VPTR **vptr,void *payload);
54 extern VPTR *vec_freeveclst(VPTR *vptr,void *(*freepayload)(void *));
55 extern unsigned int vec_sizelstlst(void **lptr);
56 extern void **vec_addlstlst(void **lptr,void *payload);
57 extern void **vec_mrglstlst(void **lptr,void **ltoadd);
58 extern int vec_rmlstlst(void **lptr,void *payload);
59 extern void **vec_freelstlst(void **lptr,void *(*freepayload)(void *));
60 #endif