[Pkg-telepathy-commits] [libnice] 49/265: tests: Use one struct for data and buffer

Simon McVittie smcv at debian.org
Wed May 14 12:04:51 UTC 2014


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian
in repository libnice.

commit b7fb6f301c2664abc55db6a2d5b0afefa5ce9368
Author: Olivier Crête <olivier.crete at collabora.com>
Date:   Fri Jan 3 18:06:51 2014 -0500

    tests: Use one struct for data and buffer
---
 tests/test-pseudotcp.c | 7 +++----
 1 file 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;
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-telepathy/libnice.git



More information about the Pkg-telepathy-commits mailing list