|
@@ -11,6 +11,7 @@
|
|
|
|
|
|
#include <stddef.h>
|
|
|
#include <stdbool.h>
|
|
|
+#include <dmmlib/heap.h>
|
|
|
|
|
|
/** The header structure of every memory block inside a heap. */
|
|
|
typedef struct block_header_s {
|
|
@@ -23,6 +24,9 @@ typedef struct block_header_s {
|
|
|
part of the previous block in the memory space */
|
|
|
void *next; /**< The next memory block in the list that the current
|
|
|
block belongs to */
|
|
|
+#ifdef WITH_OWNERSHIP
|
|
|
+ heap_t *heap_owner; /** < A pointer to the heap the current block belongs to */
|
|
|
+#endif /* WITH_OWNERSHIP */
|
|
|
} block_header_t;
|
|
|
|
|
|
/**
|
|
@@ -118,6 +122,26 @@ void set_previous_size_availability(void *ptr, size_t previous_size_availability
|
|
|
*/
|
|
|
void set_next(void *block, void *next_block);
|
|
|
|
|
|
+#ifdef WITH_OWNERSHIP
|
|
|
+
|
|
|
+/**
|
|
|
+ * Set the heap owner of a memory block
|
|
|
+ *
|
|
|
+ * \param ptr The pointer to the data part of the memory block.
|
|
|
+ * \param heap_owner The pointer to the heap owner.
|
|
|
+ */
|
|
|
+void set_owner(void *ptr, heap_t *heap_owner);
|
|
|
+
|
|
|
+/**
|
|
|
+ * Get the heap owner of a memory block
|
|
|
+ *
|
|
|
+ * \param ptr The pointer to the data part of the memory block.
|
|
|
+ * \return The pointer to the heap owner.
|
|
|
+ */
|
|
|
+heap_t * get_owner(void *ptr);
|
|
|
+
|
|
|
+#endif /* WITH_OWNERSHIP */
|
|
|
+
|
|
|
/**
|
|
|
* Check if previous block (in the memory space) belongs to a free list
|
|
|
*/
|