[Olsr-dev] [PATCH v1 3/8] txtinfo: avoid a memcpy: just move the abuf.buf pointer and clear abuf

Ferry Huberts (spam-protected)
Fri Nov 27 17:26:12 CET 2015


From: Ferry Huberts <(spam-protected)>

Signed-off-by: Ferry Huberts <(spam-protected)>
---
 lib/txtinfo/src/olsrd_txtinfo.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/txtinfo/src/olsrd_txtinfo.c b/lib/txtinfo/src/olsrd_txtinfo.c
index 429107b..1c3e860 100644
--- a/lib/txtinfo/src/olsrd_txtinfo.c
+++ b/lib/txtinfo/src/olsrd_txtinfo.c
@@ -831,12 +831,15 @@ static void send_info(unsigned int send_what, int the_socket) {
   if (send_what & SIW_OLSRD_CONF)
     ipc_print_olsrd_conf(&abuf);
 
-  outbuffer[outbuffer_count] = olsr_malloc(abuf.len, PLUGIN_NAME" output buffer");
+  /* avoid a memcpy: just move the abuf.buf pointer and clear abuf */
+  outbuffer[outbuffer_count] = abuf.buf;
   outbuffer_size[outbuffer_count] = abuf.len;
   outbuffer_written[outbuffer_count] = 0;
   outbuffer_socket[outbuffer_count] = the_socket;
+  abuf.buf = NULL;
+  abuf.len = 0;
+  abuf.size = 0;
 
-  memcpy(outbuffer[outbuffer_count], abuf.buf, abuf.len);
   outbuffer_count++;
 
   if (outbuffer_count == 1) {
-- 
2.5.0




More information about the Olsr-dev mailing list