Author: adrian.chadd
Date: Sun Feb 1 18:09:53 2009
New Revision: 13771
Modified:
branches/LUSCA_HEAD/libmem/buf.c
branches/LUSCA_HEAD/libmem/buf.h
Log:
Create a function to create a C-buffer allocation thing.
Modified: branches/LUSCA_HEAD/libmem/buf.c
==============================================================================
--- branches/LUSCA_HEAD/libmem/buf.c (original)
+++ branches/LUSCA_HEAD/libmem/buf.c Sun Feb 1 18:09:53 2009
@@ -241,3 +241,15 @@
b->b[b->len] = '\0';
return 1;
}
+
+char *
+buf_dup_cbuf(buf_t *b)
+{
+ char *c;
+
+ c = malloc(buf_len(b) + 1);
+ memcpy(c, buf_buf(b), buf_len(b));
+ c[buf_len(b)] = '\0';
+ return c;
+}
+
Modified: branches/LUSCA_HEAD/libmem/buf.h
==============================================================================
--- branches/LUSCA_HEAD/libmem/buf.h (original)
+++ branches/LUSCA_HEAD/libmem/buf.h Sun Feb 1 18:09:53 2009
@@ -43,6 +43,7 @@
extern int buf_grow_to_min_free(buf_t *b, int minfree);
extern int buf_changesize(buf_t *buf, int newsize);
extern int buf_truncate(buf_t *buf, int len, buf_flags_t
flags);
+extern char * buf_dup_cbuf(buf_t *buf);
static inline int buf_len(const buf_t *buf) { return buf->len; }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"lusca-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/lusca-commit?hl=en
-~----------~----~----~----~------~----~------~--~---