Commit a1535cdb authored by Lorenzo Miniero's avatar Lorenzo Miniero Committed by Olivier Crête

Use g_alloca instead of g_malloc_n in socket_send_messages

parent 0d0afbbd
...@@ -297,7 +297,7 @@ socket_send_messages (NiceSocket *sock, const NiceAddress *to, ...@@ -297,7 +297,7 @@ socket_send_messages (NiceSocket *sock, const NiceAddress *to,
} else { } else {
/* Multiple messages: use g_socket_send_messages, which might use /* Multiple messages: use g_socket_send_messages, which might use
* the more efficient sendmmsg if supported by the platform */ * the more efficient sendmmsg if supported by the platform */
GOutputMessage *go_messages = g_malloc_n (n_messages, sizeof (GOutputMessage)); GOutputMessage *go_messages = g_alloca (n_messages * sizeof (GOutputMessage));
for (i = 0; i < n_messages; i++) { for (i = 0; i < n_messages; i++) {
const NiceOutputMessage *message = &messages[i]; const NiceOutputMessage *message = &messages[i];
go_messages[i].address = gaddr; go_messages[i].address = gaddr;
...@@ -309,7 +309,6 @@ socket_send_messages (NiceSocket *sock, const NiceAddress *to, ...@@ -309,7 +309,6 @@ socket_send_messages (NiceSocket *sock, const NiceAddress *to,
} }
len = g_socket_send_messages (sock->fileno, go_messages, len = g_socket_send_messages (sock->fileno, go_messages,
n_messages, G_SOCKET_MSG_NONE, NULL, &child_error); n_messages, G_SOCKET_MSG_NONE, NULL, &child_error);
g_free (go_messages);
} }
if (len < 0) { if (len < 0) {
......
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