Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include <sys/queue.h>
#include <stdlib.h>
#include <stdio.h>
struct entry {
SLIST_ENTRY(entry) next;
};
SLIST_HEAD(top, entry) head;
int main() {
SLIST_INIT(&head);
struct entry *n1 = malloc(sizeof(struct entry));
SLIST_INSERT_HEAD(&head, n1, next);
struct entry *n2 = malloc(sizeof(struct entry));
SLIST_INSERT_HEAD(&head, n2, next);
struct entry *np;
SLIST_FOREACH(np, &head, next) {
printf("Helo\n");
free(np);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment