Remove casts made unneeded by the previous changeset.
[umurmur.git] / src / channel.c
index fdf4e82df9acab3a9597b56b5449d13508068b23..ec331bb1cca9b83b5daa3a04edaa6b36ca117825 100644 (file)
@@ -32,6 +32,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include "log.h"
+#include "memory.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;
 
-       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)
@@ -222,9 +220,7 @@ void Chan_init()
                else
                        ch_dst = ch_itr;
 
-               chl = malloc(sizeof(channellist_t));
-               if(!chl)
-                       Log_fatal("Out of memory");
+               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);
@@ -286,7 +282,7 @@ int Chan_userLeave(client_t *client)
 
        if (client->channel) {
                list_del(&client->chan_node);
-               leaving = (channel_t *)client->channel;
+               leaving = client->channel;
                if (leaving->temporary && list_empty(&leaving->clients)) {
                        leaving_id = leaving->id;
                        Chan_freeChannel(leaving);
@@ -300,14 +296,14 @@ int Chan_userJoin(channel_t *ch, client_t *client)
        int leaving_id;
 
        /* Do nothing if user already is in this channel */
-       if ((channel_t *)client->channel == ch)
+       if (client->channel == ch)
                return 0;
 
        Log_debug("Add user %s to channel %s", client->username, ch->name);
        /* Only allowed in one channel at a time */
        leaving_id = Chan_userLeave(client);
        list_add_tail(&client->chan_node, &ch->clients);
-       client->channel = (void *)ch;
+       client->channel = ch;
        return leaving_id;
 }
 
@@ -382,9 +378,7 @@ void Chan_buildTreeList(channel_t *ch, struct dlist *head)
        struct dlist *itr;
        channel_t *sub;
 
-       chl = malloc(sizeof(channellist_t));
-       if(!chl)
-               Log_fatal("Out of memory");
+       chl = Memory_safeMalloc(1, sizeof(channellist_t));
        chl->chan = ch;
        init_list_entry(&chl->node);
        list_add_tail(&chl->node, head);