/*
 * Make a new post from 'author' to the 'target' user,
 * containing the given contents, IF the users are friends.
 *
 * Insert the new post at the *front* of the user's list of posts.
 *
 * 'contents' is a pointer to heap-allocated memory - you do not need
 * to allocate more memory to store the contents of the post.
 *
 * Return:
 *   - 0 on success
 *   - 1 if users exist but are not friends
 *   - 2 if either User pointer is NULL
 */
int make_post(const User *author, User *target, char *contents) {
        if (author == NULL || target == NULL) {
                return 2;
        }
        if (!are_friends(author, target)) {
                return 1;
        }

        Post *new_post = (Post *)malloc(sizeof(Post));
        new_post->contents = contents;
        new_post->next = target->first_post;

        Post *p = author->first_post;
        while (p->next != NULL){
                p = p->next;
        }
        p->next = new_post;

        return 0;
}
/*
 * Make a new post from 'author' to the 'target' user,
 * containing the given contents, IF the users are friends.
 *
 * Insert the new post at the *front* of the user's list of posts.
 *
 * 'contents' is a pointer to heap-allocated memory - you do not need
 * to allocate more memory to store the contents of the post.
 *
 * Return:
 *   - 0 on success
 *   - 1 if users exist but are not friends
 *   - 2 if either User pointer is NULL
 */