From df4f869d2eb9c32dc2203c79cc1634b1849a9d7b Mon Sep 17 00:00:00 2001 From: "Anselm R. Garbe" Date: Mon, 23 Jan 2006 14:29:51 +0200 Subject: [PATCH] simplified add_channel; --- ii.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/ii.c b/ii.c index 1772b13..d25811e 100644 --- a/ii.c +++ b/ii.c @@ -119,17 +119,15 @@ static void add_channel(char *name) perror("ii: cannot create in channel"); return; } - if(!channels) - channels = c = calloc(1, sizeof(Channel)); - else { - for(c = channels; c && c->next; c = c->next); - c->next = calloc(1, sizeof(Channel)); - c = c->next; - } + c = calloc(1, sizeof(Channel)); if(!c) { perror("ii: cannot allocate memory"); exit(EXIT_FAILURE); } + if(channels) + channels = c; + else + c->next = channels; c->fd = fd; c->name = strdup(name); }