simple_list.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*-------------------------------------------------------------------------
  2. *
  3. * Simple list facilities for frontend code
  4. *
  5. * Data structures for simple lists of OIDs, strings, and pointers. The
  6. * support for these is very primitive compared to the backend's List
  7. * facilities, but it's all we need in, eg, pg_dump.
  8. *
  9. *
  10. * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
  11. * Portions Copyright (c) 1994, Regents of the University of California
  12. *
  13. * src/include/fe_utils/simple_list.h
  14. *
  15. *-------------------------------------------------------------------------
  16. */
  17. #ifndef SIMPLE_LIST_H
  18. #define SIMPLE_LIST_H
  19. typedef struct SimpleOidListCell
  20. {
  21. struct SimpleOidListCell *next;
  22. Oid val;
  23. } SimpleOidListCell;
  24. typedef struct SimpleOidList
  25. {
  26. SimpleOidListCell *head;
  27. SimpleOidListCell *tail;
  28. } SimpleOidList;
  29. typedef struct SimpleStringListCell
  30. {
  31. struct SimpleStringListCell *next;
  32. bool touched; /* true, when this string was searched and
  33. * touched */
  34. char val[FLEXIBLE_ARRAY_MEMBER]; /* null-terminated string here */
  35. } SimpleStringListCell;
  36. typedef struct SimpleStringList
  37. {
  38. SimpleStringListCell *head;
  39. SimpleStringListCell *tail;
  40. } SimpleStringList;
  41. typedef struct SimplePtrListCell
  42. {
  43. struct SimplePtrListCell *next;
  44. void *ptr;
  45. } SimplePtrListCell;
  46. typedef struct SimplePtrList
  47. {
  48. SimplePtrListCell *head;
  49. SimplePtrListCell *tail;
  50. } SimplePtrList;
  51. extern void simple_oid_list_append(SimpleOidList *list, Oid val);
  52. extern bool simple_oid_list_member(SimpleOidList *list, Oid val);
  53. extern void simple_oid_list_destroy(SimpleOidList *list);
  54. extern void simple_string_list_append(SimpleStringList *list, const char *val);
  55. extern bool simple_string_list_member(SimpleStringList *list, const char *val);
  56. extern void simple_string_list_destroy(SimpleStringList *list);
  57. extern const char *simple_string_list_not_touched(SimpleStringList *list);
  58. extern void simple_ptr_list_append(SimplePtrList *list, void *val);
  59. #endif /* SIMPLE_LIST_H */