Really set the friend alias.
[cascardo/sgp.git] / src / friend.c
index db5c457..a8c1fc6 100644 (file)
@@ -21,6 +21,7 @@
 #include <stdlib.h>
 
 struct sgp_friend {
+       char *alias;
        struct sgp_channel *channel;
 };
 
@@ -28,8 +29,27 @@ struct sgp_friend * sgp_friend_new(char *alias)
 {
        struct sgp_friend *friend;
        friend = malloc(sizeof(*friend));
+       if (!friend)
+               return NULL;
+       friend->alias = strdup(alias);
+       if (!friend->alias)
+               goto out;
        friend->channel = NULL;
        return friend;
+out:
+       free(friend);
+       return NULL;
+}
+
+void sgp_friend_destroy(struct sgp_friend *friend)
+{
+       free(friend->alias);
+       free(friend);
+}
+
+char * sgp_friend_get_alias(struct sgp_friend *friend)
+{
+       return friend->alias;
 }
 
 /*