my_list.h 1.5 KB

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