kike: introduce cstr_set()
This commit is contained in:
parent
4586b0e1e4
commit
670e1c5770
35
kike.c
35
kike.c
@ -901,8 +901,7 @@ client_unregister (struct client *c, const char *reason)
|
||||
client_add_to_whowas (c);
|
||||
|
||||
str_map_set (&c->ctx->users, c->nickname, NULL);
|
||||
free (c->nickname);
|
||||
c->nickname = NULL;
|
||||
cstr_set (&c->nickname, NULL);
|
||||
c->registered = false;
|
||||
}
|
||||
|
||||
@ -1442,11 +1441,9 @@ irc_handle_nick (const struct irc_message *msg, struct client *c)
|
||||
|
||||
// Release the old nickname and allocate a new one
|
||||
if (c->nickname)
|
||||
{
|
||||
str_map_set (&ctx->users, c->nickname, NULL);
|
||||
free (c->nickname);
|
||||
}
|
||||
c->nickname = xstrdup (nickname);
|
||||
|
||||
cstr_set (&c->nickname, xstrdup (nickname));
|
||||
str_map_set (&ctx->users, nickname, c);
|
||||
|
||||
if (!c->registered)
|
||||
@ -1469,10 +1466,8 @@ irc_handle_user (const struct irc_message *msg, struct client *c)
|
||||
if (!irc_is_valid_user (username))
|
||||
username = "xxx";
|
||||
|
||||
free (c->username);
|
||||
c->username = xstrdup (username);
|
||||
free (c->realname);
|
||||
c->realname = xstrdup (realname);
|
||||
cstr_set (&c->username, xstrdup (username));
|
||||
cstr_set (&c->realname, xstrdup (realname));
|
||||
|
||||
unsigned long m;
|
||||
if (xstrtoul (&m, mode, 10))
|
||||
@ -1872,8 +1867,7 @@ mode_processor_do_key (struct mode_processor *self)
|
||||
|
||||
str_append_c (&self->removed, self->mode_char);
|
||||
strv_append (&self->removed_params, self->channel->key);
|
||||
free (self->channel->key);
|
||||
self->channel->key = NULL;
|
||||
cstr_set (&self->channel->key, NULL);
|
||||
}
|
||||
else if (!irc_is_valid_key (target))
|
||||
// TODO: we should notify the user somehow
|
||||
@ -2532,11 +2526,9 @@ irc_handle_topic (const struct irc_message *msg, struct client *c)
|
||||
&& !(user->modes & IRC_CHAN_MODE_OPERATOR))
|
||||
RETURN_WITH_REPLY (c, IRC_ERR_CHANOPRIVSNEEDED, target);
|
||||
|
||||
free (chan->topic);
|
||||
free (chan->topic_who);
|
||||
chan->topic = xstrdup (msg->params.vector[1]);
|
||||
chan->topic_who = xstrdup_printf
|
||||
("%s!%s@%s", c->nickname, c->username, c->hostname);
|
||||
cstr_set (&chan->topic, xstrdup (msg->params.vector[1]));
|
||||
cstr_set (&chan->topic_who, xstrdup_printf
|
||||
("%s!%s@%s", c->nickname, c->username, c->hostname));
|
||||
chan->topic_time = time (NULL);
|
||||
|
||||
char *message = xstrdup_printf (":%s!%s@%s TOPIC %s :%s",
|
||||
@ -2800,14 +2792,12 @@ irc_handle_away (const struct irc_message *msg, struct client *c)
|
||||
{
|
||||
if (msg->params.len < 1)
|
||||
{
|
||||
free (c->away_message);
|
||||
c->away_message = NULL;
|
||||
cstr_set (&c->away_message, NULL);
|
||||
irc_send_reply (c, IRC_RPL_UNAWAY);
|
||||
}
|
||||
else
|
||||
{
|
||||
free (c->away_message);
|
||||
c->away_message = xstrdup (msg->params.vector[0]);
|
||||
cstr_set (&c->away_message, xstrdup (msg->params.vector[0]));
|
||||
irc_send_reply (c, IRC_RPL_NOWAWAY);
|
||||
}
|
||||
}
|
||||
@ -3362,8 +3352,7 @@ on_client_gni_resolved (int result, char *host, char *port, void *user_data)
|
||||
print_debug ("%s: %s", "getnameinfo", gai_strerror (result));
|
||||
else
|
||||
{
|
||||
free (c->hostname);
|
||||
c->hostname = xstrdup (host);
|
||||
cstr_set (&c->hostname, xstrdup (host));
|
||||
(void) port;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user