Commit 1513ce23 authored by Olivier Crête's avatar Olivier Crête

Replace g_malloc/g_new with g_alloca where possible

This should reduce the overhead a bit.
parent 524c1090
...@@ -3419,7 +3419,7 @@ agent_recv_message_unlocked ( ...@@ -3419,7 +3419,7 @@ agent_recv_message_unlocked (
n_bufs = message->n_buffers; n_bufs = message->n_buffers;
} }
local_bufs = g_malloc_n (n_bufs + 1, sizeof (GInputVector)); local_bufs = g_alloca ((n_bufs + 1) * sizeof (GInputVector));
local_message.buffers = local_bufs; local_message.buffers = local_bufs;
local_message.n_buffers = n_bufs + 1; local_message.n_buffers = n_bufs + 1;
local_message.from = message->from; local_message.from = message->from;
...@@ -3436,7 +3436,6 @@ agent_recv_message_unlocked ( ...@@ -3436,7 +3436,6 @@ agent_recv_message_unlocked (
if (retval == 1) { if (retval == 1) {
message->length = ntohs (rfc4571_frame); message->length = ntohs (rfc4571_frame);
} }
g_free (local_bufs);
} else { } else {
if (nicesock->type == NICE_SOCKET_TYPE_TCP_PASSIVE) { if (nicesock->type == NICE_SOCKET_TYPE_TCP_PASSIVE) {
NiceSocket *new_socket; NiceSocket *new_socket;
...@@ -3517,7 +3516,7 @@ agent_recv_message_unlocked ( ...@@ -3517,7 +3516,7 @@ agent_recv_message_unlocked (
n_bufs = message->n_buffers; n_bufs = message->n_buffers;
} }
local_bufs = g_malloc_n (n_bufs, sizeof (GInputVector)); local_bufs = g_alloca (n_bufs * sizeof (GInputVector));
local_message.buffers = local_bufs; local_message.buffers = local_bufs;
local_message.from = message->from; local_message.from = message->from;
local_message.length = 0; local_message.length = 0;
...@@ -3544,7 +3543,6 @@ agent_recv_message_unlocked ( ...@@ -3544,7 +3543,6 @@ agent_recv_message_unlocked (
message->length = local_message.length; message->length = local_message.length;
agent->rfc4571_expecting_length -= local_message.length; agent->rfc4571_expecting_length -= local_message.length;
} }
g_free (local_bufs);
} }
} }
} }
......
...@@ -303,7 +303,7 @@ socket_send_message (NiceSocket *sock, const NiceAddress *to, ...@@ -303,7 +303,7 @@ socket_send_message (NiceSocket *sock, const NiceAddress *to,
/* Allocate a new array of buffers, covering all the buffers in the input /* Allocate a new array of buffers, covering all the buffers in the input
* @message, but with an additional one for a header and one for a footer. */ * @message, but with an additional one for a header and one for a footer. */
local_bufs = g_malloc_n (n_bufs + 1, sizeof (GOutputVector)); local_bufs = g_alloca ((n_bufs + 1) * sizeof (GOutputVector));
local_message.buffers = local_bufs; local_message.buffers = local_bufs;
local_message.n_buffers = n_bufs + 1; local_message.n_buffers = n_bufs + 1;
...@@ -379,8 +379,6 @@ socket_send_message (NiceSocket *sock, const NiceAddress *to, ...@@ -379,8 +379,6 @@ socket_send_message (NiceSocket *sock, const NiceAddress *to,
if (ret == 1) if (ret == 1)
ret = output_message_get_size (&local_message); ret = output_message_get_size (&local_message);
g_free (local_bufs);
return ret; return ret;
} }
......
...@@ -584,7 +584,7 @@ _socket_send_messages_wrapped (NiceSocket *sock, const NiceAddress *to, ...@@ -584,7 +584,7 @@ _socket_send_messages_wrapped (NiceSocket *sock, const NiceAddress *to,
n_bufs = message->n_buffers; n_bufs = message->n_buffers;
} }
local_bufs = g_malloc_n (n_bufs + 1, sizeof (GOutputVector)); local_bufs = g_alloca ((n_bufs + 1) * sizeof (GOutputVector));
local_message.buffers = local_bufs; local_message.buffers = local_bufs;
local_message.n_buffers = n_bufs + 1; local_message.n_buffers = n_bufs + 1;
...@@ -607,8 +607,6 @@ _socket_send_messages_wrapped (NiceSocket *sock, const NiceAddress *to, ...@@ -607,8 +607,6 @@ _socket_send_messages_wrapped (NiceSocket *sock, const NiceAddress *to,
if (ret == 1) if (ret == 1)
ret = message_len; ret = message_len;
g_free (local_bufs);
return ret; return ret;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment