how can i make the code free all memory from the linked list

    Post *curr_post = temp->first_post;
    while (curr_post != NULL) {
        free(curr_post->date);
        free(curr_post);
        curr_post = NULL;
        curr_post = curr_post->next;
    }