summaryrefslogtreecommitdiffhomepage
path: root/buffer.h
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2015-03-01 21:16:09 +0800
committerMatt Johnston <matt@ucc.asn.au>2015-03-01 21:16:09 +0800
commitf367273549350d99f476ad140b083d10a212d186 (patch)
tree761c2f8cf3f5003ecf1dd7ce484d41ab4e8c6c22 /buffer.h
parent91ef9b2fa99db1ddc3a12a393472fb3a387cf959 (diff)
allocate buffer and data in a single allocation
--HG-- branch : nocircbuffer
Diffstat (limited to 'buffer.h')
-rw-r--r--buffer.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/buffer.h b/buffer.h
index 5f59939..6ab53d7 100644
--- a/buffer.h
+++ b/buffer.h
@@ -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 @@ struct buf {
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);