equal
deleted
inserted
replaced
|
1 #include "irc_user.h" |
|
2 |
|
3 #include <stdlib.h> |
|
4 #include <string.h> |
|
5 |
|
6 err_t irc_user_create (struct irc_user **user_ptr, struct irc_net *net, const char *nickname) |
|
7 { |
|
8 struct irc_user *user; |
|
9 |
|
10 // allocate |
|
11 if ((user = calloc(1, sizeof(*user))) == NULL) |
|
12 return ERR_CALLOC; |
|
13 |
|
14 // copy nickname |
|
15 if ((user->nickname = strdup(nickname)) == NULL) |
|
16 return ERR_STRDUP; |
|
17 |
|
18 // ok |
|
19 *user_ptr = user; |
|
20 |
|
21 return SUCCESS; |
|
22 } |
|
23 |
|
24 void irc_user_destroy (struct irc_user *user) |
|
25 { |
|
26 free(user->nickname); |
|
27 free(user); |
|
28 } |
|
29 |