diff buffer.h @ 1057:16584026a1f0 nocircbuffer

allocate buffer and data in a single allocation
author Matt Johnston <matt@ucc.asn.au>
date Sun, 01 Mar 2015 21:16:09 +0800
parents deed0571cacc
children 2fa71c3b2827 aaf576b27a10
line wrap: on
line diff
--- a/buffer.h	Sun Mar 01 14:46:04 2015 +0800
+++ b/buffer.h	Sun Mar 01 21:16:09 2015 +0800
@@ -29,7 +29,8 @@
 #include "includes.h"
 
 struct buf {
-
+	/* don't manipulate data member outside of buffer.c - it
+	is a pointer into the malloc holding buffer itself */
 	unsigned char * data;
 	unsigned int len; /* the used size */
 	unsigned int pos;
@@ -40,7 +41,8 @@
 typedef struct buf buffer;
 
 buffer * buf_new(unsigned int size);
-void buf_resize(buffer *buf, unsigned int newsize);
+/* Possibly returns a new buffer*, like realloc() */
+buffer * buf_resize(buffer *buf, unsigned int newsize);
 void buf_free(buffer* buf);
 void buf_burn(buffer* buf);
 buffer* buf_newcopy(buffer* buf);