summaryrefslogtreecommitdiff
path: root/shared-bindings/memorymonitor
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2020-07-16 19:01:43 -0700
committerScott Shawcroft <scott@tannewt.org>2020-07-17 17:15:03 -0700
commita1e4814a27713bd08b836cbae2afa9c858bfd4e4 (patch)
treea68e5fe0195dc0296cf70ee94eaa124c64409473 /shared-bindings/memorymonitor
parent518d909b2c20aed5b3ff1ca849731cdadea4ba4c (diff)
Get AllocationAlarm working
Diffstat (limited to 'shared-bindings/memorymonitor')
-rw-r--r--shared-bindings/memorymonitor/AllocationAlarm.c2
-rw-r--r--shared-bindings/memorymonitor/AllocationSize.c38
2 files changed, 4 insertions, 36 deletions
diff --git a/shared-bindings/memorymonitor/AllocationAlarm.c b/shared-bindings/memorymonitor/AllocationAlarm.c
index 836bf7833..71a156f32 100644
--- a/shared-bindings/memorymonitor/AllocationAlarm.c
+++ b/shared-bindings/memorymonitor/AllocationAlarm.c
@@ -76,6 +76,8 @@ STATIC mp_obj_t memorymonitor_allocationalarm_make_new(const mp_obj_type_t *type
return MP_OBJ_FROM_PTR(self);
}
+// TODO: Add .countdown(count) to skip allocations and alarm on something after the first.
+
//| def __enter__(self) -> memorymonitor.AllocationAlarm:
//| """Enables the alarm."""
//| ...
diff --git a/shared-bindings/memorymonitor/AllocationSize.c b/shared-bindings/memorymonitor/AllocationSize.c
index 411e27e15..25ecae97b 100644
--- a/shared-bindings/memorymonitor/AllocationSize.c
+++ b/shared-bindings/memorymonitor/AllocationSize.c
@@ -82,6 +82,7 @@ STATIC mp_obj_t memorymonitor_allocationsize_make_new(const mp_obj_type_t *type,
//| ...
//|
STATIC mp_obj_t memorymonitor_allocationsize_obj___enter__(mp_obj_t self_in) {
+ common_hal_memorymonitor_allocationsize_clear(self_in);
common_hal_memorymonitor_allocationsize_resume(self_in);
return self_in;
}
@@ -99,48 +100,13 @@ STATIC mp_obj_t memorymonitor_allocationsize_obj___exit__(size_t n_args, const m
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(memorymonitor_allocationsize___exit___obj, 4, 4, memorymonitor_allocationsize_obj___exit__);
-//| def pause(self) -> None:
-//| """Pause allocation tracking"""
-//| ...
-//|
-STATIC mp_obj_t memorymonitor_allocationsize_obj_pause(mp_obj_t self_in) {
- memorymonitor_allocationsize_obj_t *self = MP_OBJ_TO_PTR(self_in);
-
- common_hal_memorymonitor_allocationsize_pause(self);
- return mp_const_none;
-}
-MP_DEFINE_CONST_FUN_OBJ_1(memorymonitor_allocationsize_pause_obj, memorymonitor_allocationsize_obj_pause);
-
-//| def resume(self) -> None:
-//| """Resumes allocation tracking."""
-//| ...
-//|
-STATIC mp_obj_t memorymonitor_allocationsize_obj_resume(mp_obj_t self_in) {
- common_hal_memorymonitor_allocationsize_resume(self_in);
- return mp_const_none;
-}
-MP_DEFINE_CONST_FUN_OBJ_1(memorymonitor_allocationsize_resume_obj, memorymonitor_allocationsize_obj_resume);
-
-//| def clear(self) -> Any:
-//| """Clears all captured pulses"""
-//| ...
-//|
-STATIC mp_obj_t memorymonitor_allocationsize_obj_clear(mp_obj_t self_in) {
- memorymonitor_allocationsize_obj_t *self = MP_OBJ_TO_PTR(self_in);
-
- common_hal_memorymonitor_allocationsize_clear(self);
- return mp_const_none;
-}
-MP_DEFINE_CONST_FUN_OBJ_1(memorymonitor_allocationsize_clear_obj, memorymonitor_allocationsize_obj_clear);
-
-
//| bytes_per_block: int = ...
//| """Number of bytes per block"""
//|
STATIC mp_obj_t memorymonitor_allocationsize_obj_get_bytes_per_block(mp_obj_t self_in) {
memorymonitor_allocationsize_obj_t *self = MP_OBJ_TO_PTR(self_in);
- return mp_obj_new_bool(common_hal_memorymonitor_allocationsize_get_bytes_per_block(self));
+ return MP_OBJ_NEW_SMALL_INT(common_hal_memorymonitor_allocationsize_get_bytes_per_block(self));
}
MP_DEFINE_CONST_FUN_OBJ_1(memorymonitor_allocationsize_get_bytes_per_block_obj, memorymonitor_allocationsize_obj_get_bytes_per_block);