Skip to content

Commit

Permalink
Merge pull request #26 from dmercer-google/rename-param-new
Browse files Browse the repository at this point in the history
renaming new param in (s)list_insert_node to newNode
  • Loading branch information
sidcha authored Feb 15, 2024
2 parents 844307f + ca6c8a8 commit 79dd8bd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
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;
}
}

0 comments on commit 79dd8bd

Please sign in to comment.