what is the problem with this code?
it should work as follows:
/*
 * 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.
 */
int delete_user(const char *name, User **user_ptr_del) {
    User *prev = NULL;
    User *user = *user_ptr_del; 
    if(user == NULL){return 0;}
    while(user != NULL){
        if(strcmp(name, user->name) == 0){
            int i = 0;
            User *friend = user->friends[0];
            while(friend != NULL && i < MAX_FRIENDS){
                int j = 0;
                int indx = 0;
                while(friend->friends[j]!= NULL && j < MAX_FRIENDS){
                    if(strcmp(friend->friends[j]->name, user->name)==0){
                        indx = j;
                    }
                    j++;
                }
                if(j!=0){
                    friend->friends[indx] = friend->friends[j-1];
                    if(friend->friends[j-1]!= NULL){
                        friend->friends[j-1] = NULL;
                    }
                }
                i++;
                friend = user->friends[i];
            }

            Post* p = user->first_post;
            Post* del = NULL;
            while(p != NULL){
                free(p->contents);
                free(p->date);
                del = p;
                p = p->next;
                free(del);
            }
            user->first_post = NULL;

            if(prev == NULL){
                *user_ptr_del = user->next;
            }
            else{
                prev->next = user->next;
            }
            free(user);
            return 0;
        }
        prev = user;
        user = user -> next;
    }
    return 1;
}