path: root/firmware/include
diff options
authorThomas Martitz <>2013-11-21 11:40:04 +0100
committerThomas Martitz <>2013-12-22 23:11:32 +0100
commit64b9e1fa7b645daa36ca0018dc168d4f871fd538 (patch)
tree207a693773d001307c5f3247fd435f9bc65a192c /firmware/include
parentd25a512caf4adf2aac3ce6ac8e1f2c556c0c6c37 (diff)
buflib: Add buflib_context_relocate().
This function relocates a buflib back buffer, updating pointers in struct buflib_context. It does not move any data by itself. The intended use-case is buflib-on-buflib, where a buflib back buffer is allocated with buflib and attempted to be moved. The move_callback() can call this and return BUFLIB_CB_OK on success. No move_callback() is called for the subordinate buflib buffer, therefore it must not contain non-movable allocations. The caller is generally responsible moving the data and all its implications. Change-Id: I869219f9cff786a172c9e917a5f34470073892e6
Diffstat (limited to 'firmware/include')
1 files changed, 15 insertions, 0 deletions
diff --git a/firmware/include/buflib.h b/firmware/include/buflib.h
index aa6c232f72..0b26c04bcd 100644
--- a/firmware/include/buflib.h
+++ b/firmware/include/buflib.h
@@ -157,6 +157,21 @@ size_t buflib_available(struct buflib_context *ctx);
size_t buflib_allocatable(struct buflib_context *ctx);
+ * Relocates the fields in *ctx to the new buffer position pointed to by buf.
+ * This does _not_ move any data but updates the pointers. The data has
+ * to be moved afterwards manually and only if this function returned true.
+ *
+ * This is intended to be called from within a move_callback(), for
+ * buflib-on-buflib scenarios (i.e. a new buflib instance backed by a buffer
+ * that was allocated by another buflib instance). Be aware that if the parent
+ * move_callback() moves the underlying buffer _no_ move_callback() of the
+ * underlying buffer are called.
+ *
+ * Returns true of the relocation was successful. If it returns false no
+ * change to *ctx was made.
+ */
+bool buflib_context_relocate(struct buflib_context *ctx, void *buf);
* Allocates memory from buflib's memory pool