allow retrieving info about a supervisor allocation

crypto-aes
Jeff Epler 3 years ago committed by Jeff Epler
parent 8cba145c90
commit 094fe05bdd
  1. 1
      supervisor/memory.h
  2. 9
      supervisor/shared/memory.c

@ -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

@ -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;

Loading…
Cancel
Save