MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / listAddNodeTail

Function listAddNodeTail

src/adlist.c:115–133  ·  view source on GitHub ↗

Add a new node to the list, to tail, containing the specified 'value' * pointer as value. * * On error, NULL is returned and no operation is performed (i.e. the * list remains unaltered). * On success the 'list' pointer you pass to the function is returned. */

Source from the content-addressed store, hash-verified

113 * list remains unaltered).
114 * On success the 'list' pointer you pass to the function is returned. */
115list *listAddNodeTail(list *list, void *value)
116{
117 listNode *node;
118
119 if ((node = zmalloc(sizeof(*node), MALLOC_SHARED)) == NULL)
120 return NULL;
121 node->value = value;
122 if (list->len == 0) {
123 list->head = list->tail = node;
124 node->prev = node->next = NULL;
125 } else {
126 node->prev = list->tail;
127 node->next = NULL;
128 list->tail->next = node;
129 list->tail = node;
130 }
131 list->len++;
132 return list;
133}
134
135list *listInsertNode(list *list, listNode *old_node, void *value, int after) {
136 listNode *node;

Callers 15

scanCallbackFunction · 0.85
scanGenericCommandFunction · 0.85
pubsubSubscribeChannelFunction · 0.85
pubsubSubscribePatternFunction · 0.85
listDupFunction · 0.85
clusterManagerOnErrorFunction · 0.85

Calls 1

zmallocFunction · 0.85

Tested by

no test coverage detected