projects
/
umurmur.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix my name in the list of contributors.
[umurmur.git]
/
src
/
channel.c
diff --git
a/src/channel.c
b/src/channel.c
index 54b57a27a21421da214b04d53c8c3d7b05c28af3..346ea44ddfd9699f19da2181b77de2b85aefeab1 100644
(file)
--- a/
src/channel.c
+++ b/
src/channel.c
@@
-32,6
+32,7
@@
#include <stdlib.h>
#include <string.h>
#include "log.h"
#include <stdlib.h>
#include <string.h>
#include "log.h"
+#include "memory.h"
#include "list.h"
#include "client.h"
#include "channel.h"
#include "list.h"
#include "client.h"
#include "channel.h"
@@
-46,10
+47,7
@@
static channel_t *createChannel(int id, const char *name, const char *desc)
{
channel_t *ch;
{
channel_t *ch;
- ch = malloc(sizeof(channel_t));
- if (ch == NULL)
- Log_fatal("out of memory");
- memset(ch, 0, sizeof(channel_t));
+ ch = Memory_safeCalloc(1, sizeof(channel_t));
ch->id = id;
ch->name = strdup(name);
if (desc)
ch->id = id;
ch->name = strdup(name);
if (desc)
@@
-196,6
+194,7
@@
void Chan_init()
/* Channel links */
for (i = 0; ; i++) {
channel_t *ch_src, *ch_dst, *ch_itr = NULL;
/* Channel links */
for (i = 0; ; i++) {
channel_t *ch_src, *ch_dst, *ch_itr = NULL;
+ channellist_t *chl;
if (Conf_getNextChannelLink(&chlink, i) < 0) {
if (i == 0)
Log_info("No channel links found in configuration file.");
if (Conf_getNextChannelLink(&chlink, i) < 0) {
if (i == 0)
Log_info("No channel links found in configuration file.");
@@
-221,7
+220,10
@@
void Chan_init()
else
ch_dst = ch_itr;
else
ch_dst = ch_itr;
- list_add_tail(&ch_dst->link_node, &ch_src->channel_links);
+ chl = Memory_safeMalloc(1, sizeof(channellist_t));
+ chl->chan = ch_dst;
+ init_list_entry(&chl->node);
+ list_add_tail(&chl->node, &ch_src->channel_links);
ch_src->linkcount++;
Log_info("Adding channel link '%s' -> '%s'", ch_src->name, ch_dst->name);
}
ch_src->linkcount++;
Log_info("Adding channel link '%s' -> '%s'", ch_src->name, ch_dst->name);
}
@@
-230,6
+232,7
@@
void Chan_init()
void Chan_free()
{
struct dlist *itr, *save;
void Chan_free()
{
struct dlist *itr, *save;
+ struct dlist *linkitr, *linksave;
channel_t *ch;
list_iterate_safe(itr, save, &channels) {
channel_t *ch;
list_iterate_safe(itr, save, &channels) {
@@
-240,6
+243,11
@@
void Chan_free()
free(ch->desc);
if (ch->password)
free(ch->password);
free(ch->desc);
if (ch->password)
free(ch->password);
+ list_iterate_safe(linkitr, linksave, &ch->channel_links) {
+ channellist_t *chl;
+ chl = list_get_entry(linkitr, channellist_t, node);
+ free(chl);
+ }
free(ch);
}
}
free(ch);
}
}
@@
-370,7
+378,7
@@
void Chan_buildTreeList(channel_t *ch, struct dlist *head)
struct dlist *itr;
channel_t *sub;
struct dlist *itr;
channel_t *sub;
- chl =
malloc(
sizeof(channellist_t));
+ chl =
Memory_safeMalloc(1,
sizeof(channellist_t));
chl->chan = ch;
init_list_entry(&chl->node);
list_add_tail(&chl->node, head);
chl->chan = ch;
init_list_entry(&chl->node);
list_add_tail(&chl->node, head);