src/cx/mempool.h

changeset 1283
89935fea4b7c
parent 1281
45746a08c59e
--- a/src/cx/mempool.h	Fri Apr 11 14:49:23 2025 +0200
+++ b/src/cx/mempool.h	Fri Apr 11 15:12:20 2025 +0200
@@ -176,6 +176,29 @@
         CxMempool *dest
 );
 
+/**
+ * Transfers an object from one pool to another.
+ *
+ * You can only transfer objects that have been allocated by this pool.
+ * Objects that have been registered with cxMempoolRegister() cannot be transferred this way.
+ *
+ * @attention If the object maintains a reference to the pool's allocator,
+ * you must make sure to update that reference to the allocator of the destination pool.
+ *
+ * @param source the pool to move the memory from
+ * @param dest the pool where to transfer the memory to
+ * @param obj pointer to the object that shall be transferred
+ * @retval zero success
+ * @retval non-zero failure or object was not found in the source pool
+ */
+cx_attr_nonnull
+cx_attr_export
+int cxMempoolTransferObject(
+        CxMempool *source,
+        CxMempool *dest,
+        const void *obj
+);
+
 #ifdef __cplusplus
 } // extern "C"
 #endif

mercurial