diff packet.c @ 1055:4d7b4c5526c5 nocircbuffer

A bit of a bodge to avoid memcpy if zlib is disabled
author Matt Johnston <matt@ucc.asn.au>
date Sun, 01 Mar 2015 00:57:21 +0800
parents 0da8ba489c23
children 16584026a1f0
line wrap: on
line diff
--- a/packet.c	Sun Mar 01 00:44:45 2015 +0800
+++ b/packet.c	Sun Mar 01 00:57:21 2015 +0800
@@ -314,18 +314,21 @@
 	if (is_compress_recv()) {
 		/* decompress */
 		ses.payload = buf_decompress(ses.readbuf, len);
+		buf_setpos(ses.payload, 0);
+		ses.payload_beginning = 0;
+		buf_free(ses.readbuf);
 	} else 
 #endif
 	{
+		ses.payload = ses.readbuf;
+		ses.payload_beginning = ses.payload->pos;
+		buf_setlen(ses.payload, ses.payload->pos + len);
 		/* copy payload */
-		ses.payload = buf_new(len);
-		memcpy(ses.payload->data, buf_getptr(ses.readbuf, len), len);
-		buf_incrlen(ses.payload, len);
+		//ses.payload = buf_new(len);
+		//memcpy(ses.payload->data, buf_getptr(ses.readbuf, len), len);
+		//buf_incrlen(ses.payload, len);
 	}
-
-	buf_free(ses.readbuf);
 	ses.readbuf = NULL;
-	buf_setpos(ses.payload, 0);
 
 	ses.recvseq++;