|
@@ -25,6 +25,8 @@
|
|
|
#include "debug.h"
|
|
|
|
|
|
#include "trace.h"
|
|
|
+#include <stdbool.h>
|
|
|
+#include "dmmlib/dmmlib.h"
|
|
|
|
|
|
/** Gets the number of raw blocks that are currently managed by an allocator.
|
|
|
*
|
|
@@ -48,3 +50,29 @@ void get_raw_blocks(allocator_t *allocator) {
|
|
|
TRACE_1("dmmlib - there are %d raw blocks\n", counter);
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+/** Tries to find the raw block owner of a memory allocation.
|
|
|
+ *
|
|
|
+ * @param ptr The pointer of the memory allocation.
|
|
|
+ */
|
|
|
+raw_block_header_t *find_raw_block_owner(void *ptr) {
|
|
|
+ raw_block_header_t *current_raw_block;
|
|
|
+ bool found;
|
|
|
+
|
|
|
+ for(current_raw_block = systemallocator.raw_block_head;
|
|
|
+ current_raw_block != NULL;
|
|
|
+ current_raw_block = current_raw_block->next_raw_block) {
|
|
|
+ if(((char *)ptr > (char *)current_raw_block) &&
|
|
|
+ ((char *)ptr < (char *)current_raw_block +
|
|
|
+ current_raw_block->size)) {
|
|
|
+ found = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(found) {
|
|
|
+ return current_raw_block;
|
|
|
+ } else {
|
|
|
+ return NULL;
|
|
|
+ }
|
|
|
+}
|