Warning gets printed if alloc/free was called from an IRQ
This commit is contained in:
parent
754b43c51a
commit
b8e1a4fe57
@ -6,6 +6,10 @@
|
||||
#include "memory_pool.h"
|
||||
#include "utils.h"
|
||||
|
||||
#ifdef OS
|
||||
#include <cmsis_gcc.h>
|
||||
#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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user