summaryrefslogtreecommitdiff
path: root/socket
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2016-02-08 16:44:47 -0500
committerOlivier CrĂȘte <olivier.crete@collabora.com>2016-05-30 15:41:20 -0400
commit1513ce23ff4279dad16e177a3fc779cb61074fa1 (patch)
tree940b1f4a4b4577e8829326ffa27db738254d0cce /socket
parent524c1090cc2813bcb1be6f7f29a894c742a608f7 (diff)
downloadlibnice-1513ce23ff4279dad16e177a3fc779cb61074fa1.tar.gz
Replace g_malloc/g_new with g_alloca where possible
This should reduce the overhead a bit.
Diffstat (limited to 'socket')
-rw-r--r--socket/udp-turn-over-tcp.c4
-rw-r--r--socket/udp-turn.c4
2 files changed, 2 insertions, 6 deletions
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;
}
}