diff options
| author | Jeff Epler <jepler@gmail.com> | 2020-08-28 11:24:59 -0500 |
|---|---|---|
| committer | Jeff Epler <jepler@gmail.com> | 2020-09-01 11:00:07 -0500 |
| commit | e01ade3848cf828620ea25ada2b2b829dbe180f3 (patch) | |
| tree | 7a42d5b434df06e9c0c7a18425b328caa3528fd4 /shared-module/rgbmatrix/RGBMatrix.c | |
| parent | 2f120c70eee692b8e036f8f0778af2b723e1f0e7 (diff) | |
rgbmatrix: Don't inline the allocator functions
Diffstat (limited to 'shared-module/rgbmatrix/RGBMatrix.c')
| -rw-r--r-- | shared-module/rgbmatrix/RGBMatrix.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/shared-module/rgbmatrix/RGBMatrix.c b/shared-module/rgbmatrix/RGBMatrix.c index a020ef089..6fb36f6e3 100644 --- a/shared-module/rgbmatrix/RGBMatrix.c +++ b/shared-module/rgbmatrix/RGBMatrix.c @@ -84,7 +84,7 @@ void common_hal_rgbmatrix_rgbmatrix_reconstruct(rgbmatrix_rgbmatrix_obj_t* self, _PM_FREE(self->core.screenData); self->framebuffer = NULL; - self->bufinfo.buf = _PM_allocator_impl(self->bufsize); + self->bufinfo.buf = common_hal_rgbmatrix_allocator_impl(self->bufsize); self->bufinfo.len = self->bufsize; self->bufinfo.typecode = 'H' | MP_OBJ_ARRAY_TYPECODE_FLAG_RW; } @@ -211,3 +211,20 @@ int common_hal_rgbmatrix_rgbmatrix_get_height(rgbmatrix_rgbmatrix_obj_t* self) { int computed_height = (self->rgb_count / 3) << (self->addr_count); return computed_height; } + +void *common_hal_rgbmatrix_allocator_impl(size_t sz) { + if (gc_alloc_possible()) { + return m_malloc_maybe(sz + sizeof(void*), true); + } else { + supervisor_allocation *allocation = allocate_memory(align32_size(sz), false); + return allocation ? allocation->ptr : NULL; + } +} + +void common_hal_rgbmatrix_free_impl(void *ptr_in) { + supervisor_allocation *allocation = allocation_from_ptr(ptr_in); + + if (allocation) { + free_memory(allocation); + } +} |
