int delete_user(const char *name, User **user_ptr_del) {
    User *curr = *user_ptr_del;
    User *prev = curr;
    int found = 0;
    char *friend_names[MAX_FRIENDS] = {NULL};

    // Traverse list of users
    while (curr != NULL) {
        // Check if current user has given name
        if (strcmp(curr->name, name) == 0) {
            found = 1;
            User *curr_friend;

            // Iterate over friend list
            for (int i = 0; i < MAX_FRIENDS; i++) {
                curr_friend = (curr->friends)[i];

                // Check if current user is empty
                if (curr_friend->name == NULL) {
                    break;
                } else {
                    // If not, append name to list of friend names
                    friend_names[i] = curr_friend->name;
                }
            }

            // Remove user from user list
            if (strcmp(prev->name, curr->name) == 0) {
                // If current user is only user
                *user_ptr_del = NULL;
            } else {
                prev->next = curr->next;
            }

            break;
        }
        prev = curr;
        curr = curr->next;
    }

    // Check if user was not found
    if (!(found)) {
        return 1;
    }

    // Remove user from all friends' lists
    char *curr_friend;
    for (int i = 0; i < MAX_FRIENDS; i++) {
        curr_friend = friend_names[i];

        // Check if current user is empty
        if (curr_friend == NULL) {
            break;
        }

        // Remove user from this friend's list
        delete_friend(name, curr_friend, user_ptr_del);
    }

    // Free space allocated for user's posts
    Post *curr_post = curr->first_post;
    Post *next_post;
    while (curr_post != NULL) {
        next_post = curr_post->next;
        free(curr_post->author);
        free(curr_post->contents);
        free(curr_post->date);
        free(curr_post);
        curr_post = next_post;
    }
    // Free space allocated for user's friends
    User *friend;
    for (int i = 0; i < MAX_FRIENDS; i++) {
        friend = (curr->friends)[i];
        free(friend);
    }
    // Free space allocated for user
    printf("%s\n", curr->name);
    free(curr->name);
    if (strcmp(curr->profile_pic, "\0") != 0) {
        free(curr->profile_pic);
    }
    free(curr->friends);
    free(curr);

    return 0;
}
Function should free array of structs on line 83. Program returns invalid pointer error.