summaryrefslogtreecommitdiff
path: root/include/abuf.h
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2025-05-02 08:46:03 -0600
committerSimon Glass <sjg@chromium.org>2025-05-30 09:49:31 +0100
commitd58cebbbc7617fbc45e604c883e8501a58d25e62 (patch)
tree86b85edc452fc6efef46b3a37dfd63d04dec2a3b /include/abuf.h
parent97b586695cd80821455ae06ee178c6c8cf759ce6 (diff)
abuf: Add a function to copy a buffer
It is useful to be able to copy an abuf, to allow changes while preserving the original. Add a function for this. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/abuf.h')
-rw-r--r--include/abuf.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/abuf.h b/include/abuf.h
index 749bb188b0c..bbb3c51f334 100644
--- a/include/abuf.h
+++ b/include/abuf.h
@@ -112,6 +112,17 @@ bool abuf_realloc(struct abuf *abuf, size_t new_size);
bool abuf_realloc_inc(struct abuf *abuf, size_t inc);
/**
+ * abuf_copy() - Make a copy of an abuf
+ *
+ * Creates an allocated copy of @old in @new
+ *
+ * @old: abuf to copy
+ * @new: new abuf to hold the copy (inited by this function)
+ * Return: true if OK, false if out of memory
+ */
+bool abuf_copy(const struct abuf *old, struct abuf *new);
+
+/**
* abuf_uninit_move() - Return the allocated contents and uninit the abuf
*
* This returns the abuf data to the caller, allocating it if necessary, so that