inli.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef inli_H_INCLUDED
  2. #define inli_H_INCLUDED
  3. /**
  4. * Inli is an intrusive doubly linked list.
  5. * You will notice it has no reference to it's element,
  6. * because it should be used like this:
  7. * struct Data_ { ... }
  8. * struct DataNode_ ( struct Data_ self; Inli list; }
  9. * INLI_DATA(&list, DataNode, list)
  10. */
  11. typedef struct Inli_ Inli;
  12. struct Inli_ {
  13. Inli * next;
  14. Inli * prev;
  15. };
  16. /** Returns the list node for this list element is part of,
  17. for the give list element, and data type*/
  18. #define INLI_DATA(LIST, TYPE, MEMBER) inli_data(LIST, offsetof(TYPE, MEMBER))
  19. /** Shorthand for INLI_DATA(LIST, DATA, list) */
  20. #define INLI_LISTDATA(LIST, TYPE) INLI_DATA(LIST, TYPE, list)
  21. /* This file was generated with:
  22. 'cfunctions -c -aoff -n -w inli_proto src/inli.c' */
  23. #ifndef CFH_INLI_PROTO
  24. #define CFH_INLI_PROTO
  25. /* From 'src/inli.c': */
  26. Inli * inli_initall (Inli * self , Inli * next , Inli * prev );
  27. Inli * inli_init (Inli * self );
  28. Inli * inli_remove (Inli * self );
  29. Inli * inli_add (Inli * self , Inli * other );
  30. Inli * inli_next (Inli * self );
  31. Inli * inli_prev (Inli * self );
  32. Inli * inli_first (Inli * self );
  33. Inli * inli_last (Inli * self );
  34. Inli * inli_push (Inli * self , Inli * other );
  35. Inli * inli_unshift (Inli * self , Inli * other );
  36. Inli * inli_shift (Inli * self );
  37. Inli * inli_pop (Inli * self );
  38. void * inli_data (Inli * self , int offset );
  39. #endif /* CFH_INLI_PROTO */
  40. #endif