Created
October 11, 2015 21:00
-
-
Save Houdini/879d8805917ea64913c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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