ZJIT: Stop padding side exits (#13295)
[ruby.git] / prism / util / pm_list.c
blobad2294cd603f4b063659e28b35050914bff7ae06
1 #include "prism/util/pm_list.h"
3 /**
4 * Returns true if the given list is empty.
5 */
6 PRISM_EXPORTED_FUNCTION bool
7 pm_list_empty_p(pm_list_t *list) {
8 return list->head == NULL;
11 /**
12 * Returns the size of the list.
14 PRISM_EXPORTED_FUNCTION size_t
15 pm_list_size(pm_list_t *list) {
16 return list->size;
19 /**
20 * Append a node to the given list.
22 void
23 pm_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;
30 list->tail = node;
31 list->size++;
34 /**
35 * Deallocate the internal state of the given list.
37 PRISM_EXPORTED_FUNCTION void
38 pm_list_free(pm_list_t *list) {
39 pm_list_node_t *node = list->head;
40 pm_list_node_t *next;
42 while (node != NULL) {
43 next = node->next;
44 xfree(node);
45 node = next;
48 list->size = 0;