summaryrefslogtreecommitdiff
path: root/tests/test-pseudotcp.c
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2014-01-03 18:06:51 -0500
committerOlivier CrĂȘte <olivier.crete@collabora.com>2014-01-31 01:48:56 -0500
commitb7fb6f301c2664abc55db6a2d5b0afefa5ce9368 (patch)
tree2421b283d2436a4304292acfeb7494d22d9d3fd5 /tests/test-pseudotcp.c
parent089646764b3319efc3d1cdda25ea64e85eb74369 (diff)
downloadlibnice-b7fb6f301c2664abc55db6a2d5b0afefa5ce9368.tar.gz
tests: Use one struct for data and buffer
Diffstat (limited to 'tests/test-pseudotcp.c')
-rw-r--r--tests/test-pseudotcp.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/tests/test-pseudotcp.c b/tests/test-pseudotcp.c
index 363fcde..fcfe540 100644
--- a/tests/test-pseudotcp.c
+++ b/tests/test-pseudotcp.c
@@ -155,8 +155,8 @@ static void closed (PseudoTcpSocket *sock, guint32 err, gpointer data)
struct notify_data {
PseudoTcpSocket *sock;
- gchar *buffer;
guint32 len;
+ gchar buffer[];
};
static gboolean notify_packet (gpointer user_data)
@@ -166,7 +166,7 @@ static gboolean notify_packet (gpointer user_data)
return FALSE;
pseudo_tcp_socket_notify_packet (data->sock, data->buffer, data->len);
adjust_clock (data->sock);
- g_free (data->buffer);
+
g_free (data);
return FALSE;
}
@@ -184,11 +184,10 @@ static PseudoTcpWriteResult write (PseudoTcpSocket *sock,
return WR_SUCCESS;
}
- data = g_new0 (struct notify_data,1);
+ data = g_malloc (sizeof(struct notify_data) + len);
g_debug ("Socket %p(%d) Writing : %d bytes", sock, state, len);
- data->buffer = g_malloc (len);
memcpy (data->buffer, buffer, len);
data->len = len;