C - How can I free dynamically allocated memory?
问题 Have a look at this piece of codes, it's part of a linked list. int main() { List* head1 = NULL; insertFront(&head1, 1); insertFront(&head1, 2); print(head1); free(head1); return 0; } another function is: void insertFront(List** head, int value) { List* node = (List*)malloc(sizeof(List)); node->data = value; node->next = NULL; node->next = *head; *head = node; //free(node); essentially I am not freeing node } My questions are: Is my code going to cause memory leak problem? Should I need to