#define MAX_NAME 32     // Max username and profile_pic filename lengths
#define MAX_FRIENDS 10  // Max number of friends a user can have

typedef struct user {
    char name[MAX_NAME];
    char profile_pic[MAX_NAME];  // This is a *filename*, not the file contents.
    struct post *first_post;
    struct user *friends[MAX_FRIENDS];
    struct user *next;
} User;

typedef struct post {
    char author[MAX_NAME];
    char *contents;
    time_t *date;
    struct post *next;
} Post;

/*
 * Create a new user with the given name.  Insert it at the tail of the list
 * of users whose head is pointed to by *user_ptr_add.
 *
 * Return:
 *   - 0 if successful
 *   - 1 if a user by this name already exists in this list
 *   - 2 if the given name cannot fit in the 'name' array
 *       (don't forget about the null terminator)
 */
int create_user(const char *name, User **user_ptr_add) {
    User *curr1 = *user_ptr_add;

    //first, check if user with same name exists
    while(curr1 != NULL){
        if (strcmp(curr1->name, name) == 0){
            return 1;
        }
        curr1 = curr1->next;
    }

    // next, check if the name cannot fit in the 'name' array
    // the '-1' reserves space for the null terminator
    if (strlen(name) >= MAX_NAME - 1){
        return 2;
    }

    // create a new user and add it to the end of the list
    User *new_user = (User *)malloc(sizeof(User));
    strcpy(new_user->name, name);
    new_user->next = NULL;

    User *curr2 = *user_ptr_add;
    if (curr2 == NULL) {
    *user_ptr_add = new_user;
    }
    else {
        while (curr2->next != NULL){
            curr2 = curr2->next;
        }
        curr2->next = new_user;
    }

    return 0;
}
this function is not supposed to have any memory leaks  but it does