Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

renaming new param in (s)list_insert_node to newNode #26

Merged
merged 3 commits into from
Feb 15, 2024
Merged
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
4 changes: 2 additions & 2 deletions include/utils/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ int list_popleft(list_t *list, node_t **node);

void list_remove_node(list_t *list, node_t *node);
int list_remove_nodes(list_t *list, node_t *start, node_t *end);
void list_insert_node(list_t *list, node_t *after, node_t *new);
void list_insert_node(list_t *list, node_t *after, node_t *newNode);
int list_insert_nodes(list_t *list, node_t *after, node_t *start, node_t *end);

/*--- singly-linked list ---*/
Expand All @@ -63,7 +63,7 @@ int slist_pop(slist_t *list, snode_t *after, snode_t **node);
int slist_popleft(slist_t *list, snode_t **node);

int slist_remove_node(slist_t *list, snode_t *node);
void slist_insert_node(slist_t *list, snode_t *after, snode_t *new);
void slist_insert_node(slist_t *list, snode_t *after, snode_t *newNode);

#ifdef __cplusplus
}
Expand Down
22 changes: 11 additions & 11 deletions src/list.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,21 +160,21 @@ int list_remove_nodes(list_t *list, node_t *start, node_t *end)
return 0;
}

void list_insert_node(list_t *list, node_t *after, node_t *new)
void list_insert_node(list_t *list, node_t *after, node_t *newNode)
{
node_t *next;

if (after == NULL) {
/* insert at head */
next = list->head;
list->head = new;
list->head = newNode;
} else {
next = after->next;
after->next = new;
after->next = newNode;
}
new->prev = after;
new->next = next;
next->prev = new;
newNode->prev = after;
newNode->next = next;
next->prev = newNode;
}

int list_insert_nodes(list_t *list, node_t *after, node_t *start, node_t *end)
Expand Down Expand Up @@ -288,15 +288,15 @@ int slist_remove_node(slist_t *list, snode_t *node)
return 0;
}

void slist_insert_node(slist_t *list, snode_t *after, snode_t *new)
void slist_insert_node(slist_t *list, snode_t *after, snode_t *newNode)
{
if (after == NULL) {
/* same as append left */
new->next = list->head;
list->head = new;
newNode->next = list->head;
list->head = newNode;
} else {
/* assert after in list here? */
new->next = after->next;
after->next = new;
newNode->next = after->next;
after->next = newNode;
}
}
Loading