summaryrefslogtreecommitdiffstats
path: root/server/red_channel.c
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2010-03-11 12:13:33 +0100
committerAlexander Larsson <alexl@redhat.com>2010-03-11 12:14:08 +0100
commitd94cb8e1ba324ba5e534b6cddb604a58d7e15138 (patch)
tree0297b8b53fa7d778d6c4a89f2ef21cad1c226409 /server/red_channel.c
parentaf4672326bdd88fbdbc4bd62a2a7563dc7d2077d (diff)
downloadspice-d94cb8e1ba324ba5e534b6cddb604a58d7e15138.tar.gz
spice-d94cb8e1ba324ba5e534b6cddb604a58d7e15138.tar.xz
spice-d94cb8e1ba324ba5e534b6cddb604a58d7e15138.zip
Use spice allocator in server/
Diffstat (limited to 'server/red_channel.c')
-rw-r--r--server/red_channel.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/server/red_channel.c b/server/red_channel.c
index d8ea49dc..9364904a 100644
--- a/server/red_channel.c
+++ b/server/red_channel.c
@@ -245,11 +245,7 @@ RedChannel *red_channel_create(int size, RedsStreamContext *peer, CoreInterface
ASSERT(size >= sizeof(*channel));
ASSERT(config_socket && disconnect && handle_message && alloc_recv_buf &&
release_item);
- if (!(channel = malloc(size))) {
- red_printf("malloc failed");
- goto error1;
- }
- memset(channel, 0, size);
+ channel = spice_malloc0(size);
channel->handle_acks = handle_acks;
channel->disconnect = disconnect;
@@ -282,7 +278,7 @@ RedChannel *red_channel_create(int size, RedsStreamContext *peer, CoreInterface
channel->outgoing.on_msg_done = red_channel_peer_on_out_msg_done;
if (!config_socket(channel)) {
- goto error2;
+ goto error;
}
channel->core->set_file_handlers(channel->core, channel->peer->socket,
@@ -290,9 +286,8 @@ RedChannel *red_channel_create(int size, RedsStreamContext *peer, CoreInterface
return channel;
-error2:
+error:
free(channel);
-error1:
peer->cb_free(peer);
return NULL;
@@ -480,10 +475,7 @@ void red_channel_pipe_add_tail(RedChannel *channel, PipeItem *item)
void red_channel_pipe_add_type(RedChannel *channel, int pipe_item_type)
{
- PipeItem *item = malloc(sizeof(*item));
- if (!item) {
- red_error("malloc failed");
- }
+ PipeItem *item = spice_new(PipeItem, 1);
red_channel_pipe_item_init(channel, item, pipe_item_type);
red_channel_pipe_add(channel, item);