summaryrefslogtreecommitdiff
path: root/supervisor
diff options
context:
space:
mode:
authorJeff Epler <jepler@unpythonic.net>2020-03-25 13:40:48 -0500
committerJeff Epler <jepler@gmail.com>2020-04-14 18:24:54 -0500
commit094fe05bdd68332fa617df8a98858e324afa15ec (patch)
tree7dee6029c6a1399f24f71617afc910c52ad6d4ea /supervisor
parent8cba145c90294a001ec5814fb501a7b96a055780 (diff)
allow retrieving info about a supervisor allocation
Diffstat (limited to 'supervisor')
-rwxr-xr-xsupervisor/memory.h1
-rwxr-xr-xsupervisor/shared/memory.c9
2 files changed, 10 insertions, 0 deletions
diff --git a/supervisor/memory.h b/supervisor/memory.h
index f557744ae..f4359ca46 100755
--- a/supervisor/memory.h
+++ b/supervisor/memory.h
@@ -43,6 +43,7 @@ typedef struct {
void memory_init(void);
void free_memory(supervisor_allocation* allocation);
+supervisor_allocation* allocation_from_ptr(void *ptr);
supervisor_allocation* allocate_remaining_memory(void);
// Allocate a piece of a given length in bytes. If high_address is true then it should be allocated
diff --git a/supervisor/shared/memory.c b/supervisor/shared/memory.c
index 14c3b4979..51037bd6d 100755
--- a/supervisor/shared/memory.c
+++ b/supervisor/shared/memory.c
@@ -82,6 +82,15 @@ void free_memory(supervisor_allocation* allocation) {
allocation->ptr = NULL;
}
+supervisor_allocation* allocation_from_ptr(void *ptr) {
+ for (size_t index = 0; index < CIRCUITPY_SUPERVISOR_ALLOC_COUNT; index++) {
+ if (allocations[index].ptr == ptr) {
+ return &allocations[index];
+ }
+ }
+ return NULL;
+}
+
supervisor_allocation* allocate_remaining_memory(void) {
if (low_address == high_address) {
return NULL;