aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2020-10-04 08:32:15 +0200
committerPřemysl Eric Janouch <p@janouch.name>2020-10-04 08:32:15 +0200
commiteea761d9f7a0dacc276911c32f5451427940cbdd (patch)
treec15edd7193e1c35924d9b04eed48d0d19fbd2d02
parentdd8e543a2096cce595562bc05684eb871b742b5a (diff)
downloadxK-eea761d9f7a0dacc276911c32f5451427940cbdd.tar.gz
xK-eea761d9f7a0dacc276911c32f5451427940cbdd.tar.xz
xK-eea761d9f7a0dacc276911c32f5451427940cbdd.zip
degesch: make use of arguments in _new() functions
-rw-r--r--degesch.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/degesch.c b/degesch.c
index c73475b..d1e42e8 100644
--- a/degesch.c
+++ b/degesch.c
@@ -1287,9 +1287,10 @@ struct user_channel
};
static struct user_channel *
-user_channel_new (void)
+user_channel_new (struct channel *channel)
{
struct user_channel *self = xcalloc (1, sizeof *self);
+ self->channel = channel;
return self;
}
@@ -1325,10 +1326,11 @@ static struct ispect_field g_user_ispect[] =
};
static struct user *
-user_new (void)
+user_new (char *nickname)
{
struct user *self = xcalloc (1, sizeof *self);
self->ref_count = 1;
+ self->nickname = nickname;
return self;
}
@@ -1405,10 +1407,12 @@ static struct ispect_field g_channel_ispect[] =
};
static struct channel *
-channel_new (void)
+channel_new (char *name, char *topic)
{
struct channel *self = xcalloc (1, sizeof *self);
self->ref_count = 1;
+ self->name = name;
+ self->topic = topic;
self->no_param_modes = str_make ();
self->param_modes = str_map_make (free);
self->names_buf = strv_make ();
@@ -4376,9 +4380,8 @@ irc_make_user (struct server *s, char *nickname)
{
hard_assert (!str_map_find (&s->irc_users, nickname));
- struct user *user = user_new ();
+ struct user *user = user_new (nickname);
(void) user_weak_ref (user, irc_user_on_destroy, s);
- user->nickname = nickname;
str_map_set (&s->irc_users, user->nickname, user);
return user;
}
@@ -4435,8 +4438,7 @@ static void
irc_channel_link_user (struct channel *channel, struct user *user,
const char *prefixes)
{
- struct user_channel *user_channel = user_channel_new ();
- user_channel->channel = channel;
+ struct user_channel *user_channel = user_channel_new (channel);
LIST_PREPEND (user->channels, user_channel);
struct channel_user *channel_user = channel_user_new (user, prefixes);
@@ -4479,10 +4481,8 @@ irc_make_channel (struct server *s, char *name)
{
hard_assert (!str_map_find (&s->irc_channels, name));
- struct channel *channel = channel_new ();
+ struct channel *channel = channel_new (name, NULL);
(void) channel_weak_ref (channel, irc_channel_on_destroy, s);
- channel->name = name;
- channel->topic = NULL;
str_map_set (&s->irc_channels, channel->name, channel);
return channel;
}