Various modules solving daily C developer tasks
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.2 KiB

  1. /******************************************************************************
  2. *
  3. * Copyright (c) 2017-2019 by Löwenware Ltd
  4. * Please, refer LICENSE file for legal information
  5. *
  6. ******************************************************************************/
  7. /**
  8. * @file list.h
  9. * @author Ilja Kartašov <ik@lowenware.com>
  10. * @brief cStuff List module header file
  11. *
  12. * @see https://lowenware.com/
  13. */
  14. #ifndef CSTUFF_LIST_H_372E2D14_8DEE_4A7C_A5AB_8808A87DF436
  15. #define CSTUFF_LIST_H_372E2D14_8DEE_4A7C_A5AB_8808A87DF436
  16. #include "retcode.h"
  17. #define cstuff_list_index(LIST, IDX) (LIST->items[IDX])
  18. struct cstuff_list {
  19. void **items;
  20. int length;
  21. int size;
  22. };
  23. typedef struct cstuff_list * CStuffList;
  24. typedef void
  25. (*CStuffListFree)(void *item);
  26. CStuffRetcode
  27. cstuff_list_init(CStuffList self, int size);
  28. void
  29. cstuff_list_release(CStuffList self, CStuffListFree item_free);
  30. int
  31. cstuff_list_append(CStuffList self, void *item);
  32. int
  33. cstuff_list_insert(CStuffList self, void *item, int index);
  34. void *
  35. cstuff_list_remove(CStuffList self, int index);
  36. void
  37. cstuff_list_remove_item(CStuffList self, void *item);
  38. void
  39. cstuff_list_set_item(CStuffList self, int index, void *value);
  40. #endif /* !LIST_H */