Ruby 3.5.0dev (2025-02-22 revision b17f984e4e903d3ece3013c1488279d1947dfc39)
pm_list.c
2
7pm_list_empty_p(pm_list_t *list) {
8 return list->head == NULL;
9}
10
15pm_list_size(pm_list_t *list) {
16 return list->size;
17}
18
22void
23pm_list_append(pm_list_t *list, pm_list_node_t *node) {
24 if (list->head == NULL) {
25 list->head = node;
26 } else {
27 list->tail->next = node;
28 }
29
30 list->tail = node;
31 list->size++;
32}
33
38pm_list_free(pm_list_t *list) {
39 pm_list_node_t *node = list->head;
40 pm_list_node_t *next;
41
42 while (node != NULL) {
43 next = node->next;
44 xfree(node);
45 node = next;
46 }
47
48 list->size = 0;
49}
#define xfree
Old name of ruby_xfree.
Definition xmalloc.h:58
An abstract linked list.
#define PRISM_EXPORTED_FUNCTION
By default, we compile with -fvisibility=hidden.
Definition defines.h:53
This struct represents an abstract linked list that provides common functionality.
Definition pm_list.h:46
struct pm_list_node * next
A pointer to the next node in the list.
Definition pm_list.h:48
This represents the overall linked list.
Definition pm_list.h:55
pm_list_node_t * tail
A pointer to the tail of the list.
Definition pm_list.h:63
pm_list_node_t * head
A pointer to the head of the list.
Definition pm_list.h:60
size_t size
The size of the list.
Definition pm_list.h:57