Commit 54bb422e authored by William Sha's avatar William Sha
Browse files

Added some code for destruct, but does not operate

parent 7f41a522
......@@ -81,7 +81,7 @@ int main()
break;
case TOKEN_RMX_LI_ALL:
destruct(NULL);
destruct(default_list);
break;
}
......
......@@ -147,8 +147,29 @@ void display(List* list){
}
void destruct(List* list){
void destruct(List** list){
if (DEBUG) printf("DESTRUCT\n");
if (!*list){
printf("List is already destroyed...\n");
}
while((*list)->head != NULL){
printf("while\n");
Element* e = (*list)->head;
printf("pointeurs : list head : %p, e : %p\n", (*list)->head, e);
if((*list)->head != (*list)->tail){
printf("if\n");
(*list)->head = (*list)->head->next;
}
printf("free\n");
printf("pointeurs : list head : %p, e : %p\n", (*list)->head, e);
free(e->data);
free(e);
}
free(*list);
}
void display_menu(){
......
......@@ -28,6 +28,6 @@ int remove_element(List* list, int p);
int compare(char* str1, char* str2);
int sort(List* list);
void display(List* list);
void destruct(List* list);
void destruct(List** list);
void display_menu();
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment