/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_lstclear_test.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: lalgarra static void displaycontent(void *content) { printf("content points to %p and is ", content); if (content != NULL) printf("not NULL"); //printf("not NULL (%i)", *(int*)content); else printf("NULL"); } static void del_content(void *content) { printf("del_content(): "); displaycontent(content); printf("\n"); } static void display(t_list *node, int idx) { printf("node [%i] is ", idx); if (node == NULL) printf("NULL"); else { printf("not NULL (%p)", (void *)node); printf(", "); displaycontent(node->content); printf(", next is "); if (node->next == NULL) printf("NULL"); else printf("not NULL (%p)", (void *)node->next); } printf("\n"); } int main(void) { int ar[]={1, 2, 3, 4, 5}; t_list **list; t_list *node1; t_list *node2; node1 = ft_lstnew((void *)ar); node2 = ft_lstnew((void *)(ar + 1)); display(node1, -1); display(node2, -1); list = malloc(sizeof(t_list *)); if (list != NULL) { ft_lstadd_front(list, node1); ft_lstadd_front(list, node2); printf("My list has %i elements.\n", ft_lstsize(*list)); ft_lstclear(list, del_content); display(node1, -1); display(node2, -1); free(list); } }