@@ -78,10 +78,10 @@ void common_hal_rgbmatrix_rgbmatrix_reconstruct(rgbmatrix_rgbmatrix_obj_t* self,
78
78
// verify that the matrix is big enough
79
79
mp_get_index (mp_obj_get_type (self -> framebuffer ), self -> bufinfo .len , MP_OBJ_NEW_SMALL_INT (self -> bufsize - 1 ), false);
80
80
} else {
81
- _PM_free (self -> bufinfo .buf );
82
- _PM_free (self -> protomatter .rgbPins );
83
- _PM_free (self -> protomatter .addr );
84
- _PM_free (self -> protomatter .screenData );
81
+ common_hal_rgbmatrix_free_impl (self -> bufinfo .buf );
82
+ common_hal_rgbmatrix_free_impl (self -> protomatter .rgbPins );
83
+ common_hal_rgbmatrix_free_impl (self -> protomatter .addr );
84
+ common_hal_rgbmatrix_free_impl (self -> protomatter .screenData );
85
85
86
86
self -> framebuffer = NULL ;
87
87
self -> bufinfo .buf = common_hal_rgbmatrix_allocator_impl (self -> bufsize );
@@ -180,9 +180,6 @@ void common_hal_rgbmatrix_rgbmatrix_deinit(rgbmatrix_rgbmatrix_obj_t* self) {
180
180
181
181
void rgbmatrix_rgbmatrix_collect_ptrs (rgbmatrix_rgbmatrix_obj_t * self ) {
182
182
gc_collect_ptr (self -> framebuffer );
183
- gc_collect_ptr (self -> protomatter .rgbPins );
184
- gc_collect_ptr (self -> protomatter .addr );
185
- gc_collect_ptr (self -> protomatter .screenData );
186
183
}
187
184
188
185
void common_hal_rgbmatrix_rgbmatrix_set_paused (rgbmatrix_rgbmatrix_obj_t * self , bool paused ) {
@@ -217,18 +214,10 @@ int common_hal_rgbmatrix_rgbmatrix_get_height(rgbmatrix_rgbmatrix_obj_t* self) {
217
214
}
218
215
219
216
void * common_hal_rgbmatrix_allocator_impl (size_t sz ) {
220
- if (gc_alloc_possible ()) {
221
- return m_malloc_maybe (sz + sizeof (void * ), true);
222
- } else {
223
- supervisor_allocation * allocation = allocate_memory (align32_size (sz ), false, false);
224
- return allocation ? allocation -> ptr : NULL ;
225
- }
217
+ supervisor_allocation * allocation = allocate_memory (align32_size (sz ), false, true);
218
+ return allocation ? allocation -> ptr : NULL ;
226
219
}
227
220
228
221
void common_hal_rgbmatrix_free_impl (void * ptr_in ) {
229
- supervisor_allocation * allocation = allocation_from_ptr (ptr_in );
230
-
231
- if (allocation ) {
232
- free_memory (allocation );
233
- }
222
+ free_memory (allocation_from_ptr (ptr_in ));
234
223
}
0 commit comments