summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/abuf.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/abuf.c b/lib/abuf.c
index 3cbe320fb08..28c748acb9f 100644
--- a/lib/abuf.c
+++ b/lib/abuf.c
@@ -128,6 +128,20 @@ bool abuf_init_size(struct abuf *buf, size_t size)
return true;
}
+bool abuf_copy(const struct abuf *old, struct abuf *copy)
+{
+ char *data;
+
+ data = malloc(old->size);
+ if (!data)
+ return false;
+ memcpy(data, old->data, old->size);
+ abuf_init_set(copy, data, old->size);
+ copy->alloced = true;
+
+ return true;
+}
+
void abuf_init_const(struct abuf *abuf, const void *data, size_t size)
{
/* for now there is no flag indicating that the abuf data is constant */