
int delete_user(const char *name, User **user_ptr_del) {
    User *prev = NULL;
    User *curr = *user_ptr_del;
    while (curr != NULL) {
    if (strcmp(curr->name, name) == 0) {
    // remove user from friends lists
        int i, j;
        for (i = 0; i < MAX_FRIENDS; i++) {
            User *friend = curr->friends[i];
            if (!friend) continue;
            for (j = 0; j < MAX_FRIENDS; j++) {
                if (friend->friends[j] == curr) {
                    friend->friends[j] = NULL;
                    break;
                }
            }
        }
    
        // remove user from linked list
        if (prev == NULL) {
            *user_ptr_del = curr->next;
        } else {
            prev->next = curr->next;
        }

        // free memory
        Post *post = curr->first_post;
        while (post != NULL) {
            Post *temp = post->next;
            free(post->contents);
            free(post);
            post = temp;
        }
        free(curr);

        return 0;
    }
    prev = curr;
    curr = curr->next;
}

return 1;
}
/*
 * From the list pointed to by *user_ptr_del, delete the user
 * with the given name.
 * Remove the deleted user from any lists of friends.
 *
 * Return:
 *   - 0 on success.
 *   - 1 if a user with this name does not exist.
 */