diff options
author | Olivier CrĂȘte <olivier.crete@collabora.com> | 2016-02-08 16:44:47 -0500 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@collabora.com> | 2016-05-30 15:41:20 -0400 |
commit | 1513ce23ff4279dad16e177a3fc779cb61074fa1 (patch) | |
tree | 940b1f4a4b4577e8829326ffa27db738254d0cce | |
parent | 524c1090cc2813bcb1be6f7f29a894c742a608f7 (diff) | |
download | libnice-1513ce23ff4279dad16e177a3fc779cb61074fa1.tar.gz |
Replace g_malloc/g_new with g_alloca where possible
This should reduce the overhead a bit.
-rw-r--r-- | agent/agent.c | 6 | ||||
-rw-r--r-- | socket/udp-turn-over-tcp.c | 4 | ||||
-rw-r--r-- | socket/udp-turn.c | 4 |
3 files changed, 4 insertions, 10 deletions
diff --git a/agent/agent.c b/agent/agent.c index 1592ae4..108e87c 100644 --- a/agent/agent.c +++ b/agent/agent.c @@ -3419,7 +3419,7 @@ agent_recv_message_unlocked ( 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.n_buffers = n_bufs + 1; local_message.from = message->from; @@ -3436,7 +3436,6 @@ agent_recv_message_unlocked ( if (retval == 1) { message->length = ntohs (rfc4571_frame); } - g_free (local_bufs); } else { if (nicesock->type == NICE_SOCKET_TYPE_TCP_PASSIVE) { NiceSocket *new_socket; @@ -3517,7 +3516,7 @@ agent_recv_message_unlocked ( 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.from = message->from; local_message.length = 0; @@ -3544,7 +3543,6 @@ agent_recv_message_unlocked ( message->length = local_message.length; agent->rfc4571_expecting_length -= local_message.length; } - g_free (local_bufs); } } } diff --git a/socket/udp-turn-over-tcp.c b/socket/udp-turn-over-tcp.c index fb788b3..52c1189 100644 --- a/socket/udp-turn-over-tcp.c +++ b/socket/udp-turn-over-tcp.c @@ -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 * @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.n_buffers = n_bufs + 1; @@ -379,8 +379,6 @@ socket_send_message (NiceSocket *sock, const NiceAddress *to, if (ret == 1) ret = output_message_get_size (&local_message); - g_free (local_bufs); - return ret; } diff --git a/socket/udp-turn.c b/socket/udp-turn.c index d0e20b2..0ab99f3 100644 --- a/socket/udp-turn.c +++ b/socket/udp-turn.c @@ -584,7 +584,7 @@ _socket_send_messages_wrapped (NiceSocket *sock, const NiceAddress *to, 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.n_buffers = n_bufs + 1; @@ -607,8 +607,6 @@ _socket_send_messages_wrapped (NiceSocket *sock, const NiceAddress *to, if (ret == 1) ret = message_len; - g_free (local_bufs); - return ret; } } |