File indexing completed on 2025-02-22 10:47:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef LIBPKGCONF_ITER_H
0017 #define LIBPKGCONF_ITER_H
0018
0019 #ifdef __cplusplus
0020 extern "C" {
0021 #endif
0022
0023 typedef struct pkgconf_node_ pkgconf_node_t;
0024
0025 struct pkgconf_node_ {
0026 pkgconf_node_t *prev, *next;
0027 void *data;
0028 };
0029
0030 typedef struct {
0031 pkgconf_node_t *head, *tail;
0032 size_t length;
0033 } pkgconf_list_t;
0034
0035 #define PKGCONF_LIST_INITIALIZER { NULL, NULL, 0 }
0036
0037 static inline void
0038 pkgconf_list_zero(pkgconf_list_t *list)
0039 {
0040 list->head = NULL;
0041 list->tail = NULL;
0042 list->length = 0;
0043 }
0044
0045 static inline void
0046 pkgconf_node_insert(pkgconf_node_t *node, void *data, pkgconf_list_t *list)
0047 {
0048 pkgconf_node_t *tnode;
0049
0050 node->data = data;
0051
0052 if (list->head == NULL)
0053 {
0054 list->head = node;
0055 list->tail = node;
0056 list->length = 1;
0057 return;
0058 }
0059
0060 tnode = list->head;
0061
0062 node->next = tnode;
0063 tnode->prev = node;
0064
0065 list->head = node;
0066 list->length++;
0067 }
0068
0069 static inline void
0070 pkgconf_node_insert_tail(pkgconf_node_t *node, void *data, pkgconf_list_t *list)
0071 {
0072 pkgconf_node_t *tnode;
0073
0074 node->data = data;
0075
0076 if (list->tail == NULL)
0077 {
0078 list->head = node;
0079 list->tail = node;
0080 list->length = 1;
0081 return;
0082 }
0083
0084 tnode = list->tail;
0085
0086 node->prev = tnode;
0087 tnode->next = node;
0088
0089 list->tail = node;
0090 list->length++;
0091 }
0092
0093 static inline void
0094 pkgconf_node_delete(pkgconf_node_t *node, pkgconf_list_t *list)
0095 {
0096 list->length--;
0097
0098 if (node->prev == NULL)
0099 list->head = node->next;
0100 else
0101 node->prev->next = node->next;
0102
0103 if (node->next == NULL)
0104 list->tail = node->prev;
0105 else
0106 node->next->prev = node->prev;
0107 }
0108
0109 #ifdef __cplusplus
0110 }
0111 #endif
0112
0113 #endif