properly initialize new list items

master
orange 11 years ago
parent 7e828ad441
commit ff5ec6af02

@ -50,6 +50,8 @@ void list_print(list_t * list) {
void list_add(list_t * list, list_node_t * item) {
list_node_t *cur;
assert(item->next == NULL);
if (list_empty(list)) {
list->head = item;
} else {
@ -143,6 +145,7 @@ int main(int argc, char *argv[]) {
for (int i = 0; i < howmany; i++) {
list_node_t *newnode = malloc(sizeof(list_node_t));
newnode->data = i;
newnode->next = NULL;
list_add(foolist, newnode);
}
@ -200,6 +203,7 @@ int main(int argc, char *argv[]) {
for (int i = 0; i < howmany2; i++) {
list_node_t *newnode = malloc(sizeof(list_node_t));
newnode->data = i;
newnode->next = NULL;
list_add(foolist, newnode);
}

Loading…
Cancel
Save