X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=src%2Fchannel.c;h=1e71be3db880492061e52e3495aa91665565a581;hb=a1013f3e2787bee84a06fbb9f6986d63bcec2846;hp=d55653b50b9c1300b9dff9e299c0768bdc6186a0;hpb=01e804f06e00c36c5680ebde07cbe17e6b256dc4;p=umurmur.git diff --git a/src/channel.c b/src/channel.c index d55653b..1e71be3 100644 --- a/src/channel.c +++ b/src/channel.c @@ -49,8 +49,9 @@ static channel_t *createChannel(int id, const char *name, const char *desc) Log_fatal("out of memory"); memset(ch, 0, sizeof(channel_t)); ch->id = id; - strncpy(ch->name, name, MAX_TEXT); - strncpy(ch->desc, desc, MAX_TEXT); + ch->name = strdup(name); + if (desc) + ch->desc = strdup(desc); init_list_entry(&ch->subs); init_list_entry(&ch->node); init_list_entry(&ch->clients); @@ -139,7 +140,7 @@ void Chan_init() conf_channel_link_t chlink; const char *defaultChannelName; - defaultChannelName = getStrConf(DEAFULT_CHANNEL); + defaultChannelName = getStrConf(DEFAULT_CHANNEL); for (i = 0; ; i++) { if (Conf_getNextChannel(&chdesc, i) < 0) { @@ -195,7 +196,8 @@ void Chan_init() Chan_iterate(&ch_itr); } while (ch_itr != NULL && strcmp(ch_itr->name, chlink.source) != 0); if (ch_itr == NULL) - Log_fatal("Error in channel link configuration: source channel '%s' not found.", chlink.source); + Log_fatal("Error in channel link configuration: source channel '%s' not found.", + chlink.source); else ch_src = ch_itr; @@ -204,7 +206,8 @@ void Chan_init() Chan_iterate(&ch_itr); } while (ch_itr != NULL && strcmp(ch_itr->name, chlink.destination) != 0); if (ch_itr == NULL) - Log_fatal("Error in channel link configuration: destination channel '%s' not found", chlink.destination); + Log_fatal("Error in channel link configuration: destination channel '%s' not found", + chlink.destination); else ch_dst = ch_itr; @@ -216,10 +219,15 @@ void Chan_init() void Chan_free() { struct dlist *itr, *save; + channel_t *ch; list_iterate_safe(itr, save, &channels) { - Log_debug("Free channel %s", list_get_entry(itr, channel_t, flatlist_node)->name); - free(list_get_entry(itr, channel_t, flatlist_node)); + ch = list_get_entry(itr, channel_t, flatlist_node); + Log_debug("Free channel %s", ch->name); + free(ch->name); + if (ch->desc) + free(ch->desc); + free(ch); } }