Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/util/lists.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

void oc_list_init(oc_list* list)
{
list->first = list->last = 0;
memset(list, 0, sizeof(oc_list));
}

void oc_list_insert(oc_list* list, oc_list_elt* afterElt, oc_list_elt* elt)
Expand All @@ -27,6 +27,7 @@ void oc_list_insert(oc_list* list, oc_list_elt* afterElt, oc_list_elt* elt)
list->last = elt;
}
afterElt->next = elt;
list->len++;

OC_DEBUG_ASSERT(elt->next != elt, "oc_list_insert(): can't insert an element into itself");
}
Expand All @@ -46,6 +47,7 @@ void oc_list_insert_before(oc_list* list, oc_list_elt* beforeElt, oc_list_elt* e
}
beforeElt->prev = elt;

list->len++;
OC_DEBUG_ASSERT(elt->next != elt, "oc_list_insert_before(): can't insert an element into itself");
}

Expand All @@ -70,6 +72,8 @@ void oc_list_remove(oc_list* list, oc_list_elt* elt)
list->last = elt->prev;
}
elt->prev = elt->next = 0;
OC_DEBUG_ASSERT(list->len);
list->len--;
}

void oc_list_push_front(oc_list* list, oc_list_elt* elt)
Expand All @@ -85,6 +89,7 @@ void oc_list_push_front(oc_list* list, oc_list_elt* elt)
list->last = elt;
}
list->first = elt;
list->len++;
}

oc_list_elt* oc_list_pop_front(oc_list* list)
Expand Down Expand Up @@ -114,6 +119,7 @@ void oc_list_push_back(oc_list* list, oc_list_elt* elt)
list->first = elt;
}
list->last = elt;
list->len++;
}

oc_list_elt* oc_list_pop_back(oc_list* list)
Expand Down
1 change: 1 addition & 0 deletions src/util/lists.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ typedef struct oc_list
{
oc_list_elt* first;
oc_list_elt* last;
u64 len;
} oc_list;

ORCA_API bool oc_list_empty(oc_list list);
Expand Down
Loading