degesch: make use of arguments in _new() functions
This commit is contained in:
parent
dd8e543a20
commit
eea761d9f7
20
degesch.c
20
degesch.c
|
@ -1287,9 +1287,10 @@ struct user_channel
|
||||||
};
|
};
|
||||||
|
|
||||||
static 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);
|
struct user_channel *self = xcalloc (1, sizeof *self);
|
||||||
|
self->channel = channel;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1325,10 +1326,11 @@ static struct ispect_field g_user_ispect[] =
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct user *
|
static struct user *
|
||||||
user_new (void)
|
user_new (char *nickname)
|
||||||
{
|
{
|
||||||
struct user *self = xcalloc (1, sizeof *self);
|
struct user *self = xcalloc (1, sizeof *self);
|
||||||
self->ref_count = 1;
|
self->ref_count = 1;
|
||||||
|
self->nickname = nickname;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1405,10 +1407,12 @@ static struct ispect_field g_channel_ispect[] =
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct channel *
|
static struct channel *
|
||||||
channel_new (void)
|
channel_new (char *name, char *topic)
|
||||||
{
|
{
|
||||||
struct channel *self = xcalloc (1, sizeof *self);
|
struct channel *self = xcalloc (1, sizeof *self);
|
||||||
self->ref_count = 1;
|
self->ref_count = 1;
|
||||||
|
self->name = name;
|
||||||
|
self->topic = topic;
|
||||||
self->no_param_modes = str_make ();
|
self->no_param_modes = str_make ();
|
||||||
self->param_modes = str_map_make (free);
|
self->param_modes = str_map_make (free);
|
||||||
self->names_buf = strv_make ();
|
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));
|
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);
|
(void) user_weak_ref (user, irc_user_on_destroy, s);
|
||||||
user->nickname = nickname;
|
|
||||||
str_map_set (&s->irc_users, user->nickname, user);
|
str_map_set (&s->irc_users, user->nickname, user);
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
@ -4435,8 +4438,7 @@ static void
|
||||||
irc_channel_link_user (struct channel *channel, struct user *user,
|
irc_channel_link_user (struct channel *channel, struct user *user,
|
||||||
const char *prefixes)
|
const char *prefixes)
|
||||||
{
|
{
|
||||||
struct user_channel *user_channel = user_channel_new ();
|
struct user_channel *user_channel = user_channel_new (channel);
|
||||||
user_channel->channel = channel;
|
|
||||||
LIST_PREPEND (user->channels, user_channel);
|
LIST_PREPEND (user->channels, user_channel);
|
||||||
|
|
||||||
struct channel_user *channel_user = channel_user_new (user, prefixes);
|
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));
|
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);
|
(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);
|
str_map_set (&s->irc_channels, channel->name, channel);
|
||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue