Set the friend alias, make it more robust to fail to create a friend and
allow it to be destroyed.
struct sgp_friend;
struct sgp_friend * sgp_friend_new(char *);
+void sgp_friend_destroy(struct sgp_friend *);
+char * sgp_friend_get_alias(struct sgp_friend *);
struct sgp_channel * sgp_friend_get_channel(struct sgp_friend *);
#include <stdlib.h>
struct sgp_friend {
+ char *alias;
struct sgp_channel *channel;
};
{
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;
}
/*