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. */
| 113 | * list remains unaltered). |
| 114 | * On success the 'list' pointer you pass to the function is returned. */ |
| 115 | list *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 | |
| 135 | list *listInsertNode(list *list, listNode *old_node, void *value, int after) { |
| 136 | listNode *node; |
no test coverage detected