aboutsummaryrefslogtreecommitdiffstats
path: root/irc_channel.c
diff options
context:
space:
mode:
Diffstat (limited to 'irc_channel.c')
-rw-r--r--irc_channel.c49
1 files changed, 12 insertions, 37 deletions
diff --git a/irc_channel.c b/irc_channel.c
index 583b6d20..739360de 100644
--- a/irc_channel.c
+++ b/irc_channel.c
@@ -871,9 +871,9 @@ static char *set_eval_by_account(set_t *set, char *value)
struct irc_channel *ic = set->data;
struct irc_control_channel *icc = ic->data;
account_t *acc;
- struct acclist *accl, *tmp, *new_acc = NULL;
-
+ GSList *accl, *new_acc = NULL;
char **accounts, **account;
+
accounts = g_strsplit(value, ",", 0);
if (accounts == NULL) {
goto fail;
@@ -883,25 +883,14 @@ static char *set_eval_by_account(set_t *set, char *value)
if (!(acc = account_get(ic->irc->b, *account))) {
goto fail;
} else {
- tmp = g_malloc(sizeof(struct account));
- if (tmp == NULL) {
- goto fail;
- } else {
- tmp->acc = acc;
- tmp->next = new_acc;
- new_acc = tmp;
- }
+ new_acc = g_slist_append(new_acc, account);
}
}
- accl = (struct acclist *)icc->account;
- while (accl) {
- tmp = accl->next;
- g_free(accl);
- accl = tmp;
- }
+ accl = icc->account;
+ g_slist_free(accl);
- icc->account = (struct account *)new_acc;
+ icc->account = new_acc;
if ((icc->type & IRC_CC_TYPE_MASK) == IRC_CC_TYPE_ACCOUNT) {
bee_irc_channel_update(ic->irc, ic, NULL);
}
@@ -911,13 +900,7 @@ static char *set_eval_by_account(set_t *set, char *value)
return g_strdup(value);
fail:
- accl = new_acc;
- while (accl) {
- tmp = accl->next;
- g_free(accl);
- accl = tmp;
- }
-
+ g_slist_free(new_acc);
g_strfreev(accounts);
return SET_INVALID;
@@ -1044,7 +1027,7 @@ fail:
gboolean irc_channel_wants_user(irc_channel_t *ic, irc_user_t *iu)
{
struct irc_control_channel *icc = ic->data;
- struct acclist *accl;
+ GSList *accl;
gboolean ret = FALSE;
if (iu->bu == NULL) {
@@ -1056,13 +1039,12 @@ gboolean irc_channel_wants_user(irc_channel_t *ic, irc_user_t *iu)
ret = iu->bu->group == icc->group;
break;
case IRC_CC_TYPE_ACCOUNT:
- accl = (struct acclist *)icc->account;
- while (accl) {
- if (iu->bu->ic->acc == accl->acc) {
+ for (accl = icc->account; accl; accl = accl->next) {
+ account_t *acc = accl->data;
+ if (iu->bu->ic->acc == acc) {
ret = TRUE;
break;
}
- accl = accl->next;
}
break;
case IRC_CC_TYPE_PROTOCOL:
@@ -1084,7 +1066,6 @@ gboolean irc_channel_wants_user(irc_channel_t *ic, irc_user_t *iu)
static gboolean control_channel_free(irc_channel_t *ic)
{
struct irc_control_channel *icc = ic->data;
- struct acclist *accl, *tmp;
set_del(&ic->set, "account");
set_del(&ic->set, "fill_by");
@@ -1092,13 +1073,7 @@ static gboolean control_channel_free(irc_channel_t *ic)
set_del(&ic->set, "protocol");
set_del(&ic->set, "show_users");
- accl = (struct acclist *)icc->account;
- while (accl) {
- tmp = accl->next;
- g_free(accl);
- accl = tmp;
- }
-
+ g_slist_free(icc->account);
g_free(icc);
ic->data = NULL;