jsoninfo: avoid a memcpy: just move the abuf.buf pointer and clear abuf
authorFerry Huberts <ferry.huberts@pelagic.nl>
Fri, 27 Nov 2015 12:58:45 +0000 (13:58 +0100)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Fri, 27 Nov 2015 16:10:01 +0000 (17:10 +0100)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/jsoninfo/src/olsrd_jsoninfo.c

index 2ba7efc..86c7d83 100644 (file)
@@ -1259,12 +1259,15 @@ static void send_info(unsigned int send_what, int the_socket) {
     http_header_adjust_content_length(&abuf, contentLengthPlaceholderStart, abuf.len - headerLength);
   }
 
-  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) {