Skip to content

Commit a35e774

Browse files
committed
Add documentation and const to various list functions.
1 parent 62a23d5 commit a35e774

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

ext/io/event/selector/list.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ inline static void IO_Event_List_append(struct IO_Event_List *list, struct IO_Ev
3838
head->tail = node;
3939
}
4040

41+
// Prepend an item to the beginning of the list.
4142
inline static void IO_Event_List_prepend(struct IO_Event_List *list, struct IO_Event_List *node)
4243
{
4344
assert(node->head == NULL);
@@ -64,18 +65,20 @@ inline static void IO_Event_List_pop(struct IO_Event_List *node)
6465
node->head = node->tail = NULL;
6566
}
6667

68+
// Remove an item from the list, if it is in a list.
6769
inline static void IO_Event_List_free(struct IO_Event_List *node)
6870
{
6971
if (node->head && node->tail) {
7072
IO_Event_List_pop(node);
7173
}
7274
}
7375

74-
inline static size_t IO_Event_List_memory_size(struct IO_Event_List *list)
76+
// Calculate the memory size of the list nodes.
77+
inline static size_t IO_Event_List_memory_size(const struct IO_Event_List *list)
7578
{
7679
size_t memsize = 0;
7780

78-
struct IO_Event_List *node = list->tail;
81+
const struct IO_Event_List *node = list->tail;
7982
while (node != list) {
8083
memsize += sizeof(struct IO_Event_List);
8184
node = node->tail;
@@ -84,11 +87,13 @@ inline static size_t IO_Event_List_memory_size(struct IO_Event_List *list)
8487
return memsize;
8588
}
8689

87-
inline static int IO_Event_List_empty(struct IO_Event_List *list)
90+
// Return true if the list is empty.
91+
inline static int IO_Event_List_empty(const struct IO_Event_List *list)
8892
{
8993
return list->head == list->tail;
9094
}
9195

96+
// Enumerate all items in the list, assuming the list will not be modified during iteration.
9297
inline static void IO_Event_List_immutable_each(struct IO_Event_List *list, void (*callback)(struct IO_Event_List *node))
9398
{
9499
struct IO_Event_List *node = list->tail;

0 commit comments

Comments
 (0)