summaryrefslogtreecommitdiff
path: root/shared-module/_protomatter/Protomatter.c
diff options
context:
space:
mode:
authorJeff Epler <jepler@gmail.com>2020-04-01 11:59:15 -0500
committerJeff Epler <jepler@gmail.com>2020-04-14 18:24:58 -0500
commit3a94412cd35c39bf30f29cb2b79be3870709c809 (patch)
tree8a2653aa8a7ca665f0f70b74172cc964d33504b2 /shared-module/_protomatter/Protomatter.c
parent1d8a073c05c36133e02d839ed187b9d7abf24d79 (diff)
protomatter: more memory allocation fixes
- bump supervisor alloc count by 4 (we actually use 5) - move reconstruct to after gc heap is reset - destroy protomatter object entirely if not used by a FramebufferDisplay - ensure previous supervisor allocations are released - zero out pointers so GC can collect them
Diffstat (limited to 'shared-module/_protomatter/Protomatter.c')
-rw-r--r--shared-module/_protomatter/Protomatter.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/shared-module/_protomatter/Protomatter.c b/shared-module/_protomatter/Protomatter.c
index cbb60db6d..bec9586f8 100644
--- a/shared-module/_protomatter/Protomatter.c
+++ b/shared-module/_protomatter/Protomatter.c
@@ -78,6 +78,11 @@ void common_hal_protomatter_protomatter_reconstruct(protomatter_protomatter_obj_
// verify that the matrix is big enough
mp_get_index(mp_obj_get_type(self->framebuffer), self->bufinfo.len, MP_OBJ_NEW_SMALL_INT(self->bufsize-1), false);
} else {
+ _PM_FREE(self->bufinfo.buf);
+ _PM_FREE(self->core.rgbPins);
+ _PM_FREE(self->core.addr);
+ _PM_FREE(self->core.screenData);
+
self->framebuffer = NULL;
self->bufinfo.buf = _PM_allocator_impl(self->bufsize);
self->bufinfo.len = self->bufsize;
@@ -156,6 +161,7 @@ void common_hal_protomatter_protomatter_deinit(protomatter_protomatter_obj_t* se
if (self->core.rgbPins) {
_PM_free(&self->core);
}
+ memset(&self->core, 0, sizeof(self->core));
self->base.type = NULL;
}