root/src/mysql/my_list.h

Revision 1, 1.5 kB (checked in by jinshiro, 17 years ago)
Line 
1/* Copyright (C) 2000 MySQL AB
2
3   This program is free software; you can redistribute it and/or modify
4   it under the terms of the GNU General Public License as published by
5   the Free Software Foundation; either version 2 of the License, or
6   (at your option) any later version.
7
8   This program is distributed in the hope that it will be useful,
9   but WITHOUT ANY WARRANTY; without even the implied warranty of
10   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11   GNU General Public License for more details.
12
13   You should have received a copy of the GNU General Public License
14   along with this program; if not, write to the Free Software
15   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
16
17#ifndef _list_h_
18#define _list_h_
19
20#ifdef  __cplusplus
21extern "C" {
22#endif
23
24typedef struct st_list {
25  struct st_list *prev,*next;
26  void *data;
27} LIST;
28
29typedef int (*list_walk_action)(void *,void *);
30
31extern LIST *list_add(LIST *root,LIST *element);
32extern LIST *list_delete(LIST *root,LIST *element);
33extern LIST *list_cons(void *data,LIST *root);
34extern LIST *list_reverse(LIST *root);
35extern void list_free(LIST *root,unsigned int free_data);
36extern unsigned int list_length(LIST *);
37extern int list_walk(LIST *,list_walk_action action,gptr argument);
38
39#define list_rest(a) ((a)->next)
40#define list_push(a,b) (a)=list_cons((b),(a))
41#define list_pop(A) {LIST *old=(A); (A)=list_delete(old,old) ; my_free((gptr) old,MYF(MY_FAE)); }
42
43#ifdef  __cplusplus
44}
45#endif
46#endif
Note: See TracBrowser for help on using the browser.