Skip to content

Instantly share code, notes, and snippets.

@devendranaga
Created January 22, 2019 07:34
Show Gist options
  • Save devendranaga/65f16a921006d61a81384724f5be87d8 to your computer and use it in GitHub Desktop.
Save devendranaga/65f16a921006d61a81384724f5be87d8 to your computer and use it in GitHub Desktop.
int list_add_tail(void *data)
{
struct linked_list *t;
t = malloc(sizeof(struct linked_list));
if (!t) {
return -1;
}
t->data = data;
if (!head) { // no head element yet..
head = t;
tail = t;
} else { // add it at the tail..
tail->next = t;
tail = t;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment