diff --git a/memory_pool.c b/memory_pool.c index c402324..dc941d3 100644 --- a/memory_pool.c +++ b/memory_pool.c @@ -6,6 +6,10 @@ #include "memory_pool.h" #include "utils.h" +#ifdef OS +#include +#endif + MP *mp_init(uint8_t *p, uint32_t size) { ASSERT_BAD_ALIGN(p); // check for alignment size = FLOOR_TO_4(size); // force alignment on size @@ -60,6 +64,13 @@ uint8_t *mp_alloc(MP *mp, uint32_t size) { // make the allocation from the beginning of the smallest suitable (large enough) // contiguous block +#ifdef OS + // warn if allocation is made from an IRQ + if (__get_IPSR()) { + MSG("Alloc from IRQ!\n"); + } +#endif + // round size to make it divisible by 4 size = CEIL_TO_4(size); @@ -141,6 +152,13 @@ void mp_free(MP *mp, const uint8_t *p) { return; } +#ifdef OS + // warn if memory block is getting released from an IRQ + if (__get_IPSR()) { + MSG("Free from IRQ!\n"); + } +#endif + // look for registry record bool success = false; MPAllocRecord *recIter = mp->blockRegistry;