/*
 * 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) {
    // Checks if either user pointer are NULL
    if (author == NULL || target == NULL) {
        return 2;
    }
    // Checks if users are friends
    int i = 0;
    int they_are_friends = 0;
    while (i < MAX_FRIENDS) {
        if ((author->friends[i] != NULL) && author->friends[i]->name == target->name) {
            they_are_friends += 1;
        }
        if ((target->friends[i] != NULL) && target->friends[i]->name == author->name) {
            they_are_friends += 1;
        }
        i += 1;
    }
    if (they_are_friends == 0) {
        return 1;
    }
    else {
        // SEG FAULT HERE!!!
        // They are friends and add post content to target's profile
        Post *a_post = (Post *)malloc(sizeof(Post));
        strcpy(a_post->author, (char *) author);
        strcpy(a_post->contents, contents); // IDK About this part
        // Get time
        time_t posted_datetime = time(NULL);
        *a_post->date = posted_datetime;
        
        // Insert new post
        if (target->first_post != NULL) {
            // NOT too sure about this part 
            a_post->next = target->first_post;
            target->first_post = a_post->next; 
        }
        else{
            target->first_post = a_post;
            a_post->next = NULL;
        }
        return 0;
    }
}
How to make Post properly and get rid of segmentation fault?