summaryrefslogtreecommitdiff
path: root/shared-module/memorymonitor/AllocationAlarm.c
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2020-07-17 17:02:13 -0700
committerScott Shawcroft <scott@tannewt.org>2020-07-17 17:15:04 -0700
commit07f031c70840352893e7137abbf7d564c3d4a0b7 (patch)
treece168f36e6628d95ac6f844632a6461cf02e6744 /shared-module/memorymonitor/AllocationAlarm.c
parenta1e4814a27713bd08b836cbae2afa9c858bfd4e4 (diff)
Add ignore() and fix docs
Diffstat (limited to 'shared-module/memorymonitor/AllocationAlarm.c')
-rw-r--r--shared-module/memorymonitor/AllocationAlarm.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/shared-module/memorymonitor/AllocationAlarm.c b/shared-module/memorymonitor/AllocationAlarm.c
index ed7ab75ab..35f4e4c63 100644
--- a/shared-module/memorymonitor/AllocationAlarm.c
+++ b/shared-module/memorymonitor/AllocationAlarm.c
@@ -37,6 +37,10 @@ void common_hal_memorymonitor_allocationalarm_construct(memorymonitor_allocation
self->previous = NULL;
}
+void common_hal_memorymonitor_allocationalarm_set_ignore(memorymonitor_allocationalarm_obj_t* self, mp_int_t count) {
+ self->count = count;
+}
+
void common_hal_memorymonitor_allocationalarm_pause(memorymonitor_allocationalarm_obj_t* self) {
// Check to make sure we aren't already paused. We can be if we're exiting from an exception we
// caused.
@@ -67,12 +71,16 @@ void memorymonitor_allocationalarms_allocation(size_t block_count) {
// Hold onto next in case we remove the alarm from the list.
memorymonitor_allocationalarm_obj_t* next = alarm->next;
if (block_count >= alarm->minimum_block_count) {
- // Uncomment the breakpoint below if you want to use a C debugger to figure out the C
- // call stack for an allocation.
- // asm("bkpt");
- // Pause now because we may alert when throwing the exception too.
- common_hal_memorymonitor_allocationalarm_pause(alarm);
- alert_count++;
+ if (alarm->count > 0) {
+ alarm->count--;
+ } else {
+ // Uncomment the breakpoint below if you want to use a C debugger to figure out the C
+ // call stack for an allocation.
+ // asm("bkpt");
+ // Pause now because we may alert when throwing the exception too.
+ common_hal_memorymonitor_allocationalarm_pause(alarm);
+ alert_count++;
+ }
}
alarm = next;
}