ma_list.h 1.6 KB

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