Skip to content

Commit e8e5254

Browse files
committed
Bitmaps in tlsf heap
1 parent 6327eaf commit e8e5254

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

shared-module/displayio/Bitmap.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ void common_hal_displayio_bitmap_construct_from_buffer(displayio_bitmap_t *self,
3131
self->stride = stride(width, bits_per_value);
3232
self->data_alloc = false;
3333
if (!data) {
34-
data = m_malloc(self->stride * height * sizeof(uint32_t));
34+
size_t bitmap_bytes = self->stride * height * sizeof(uint32_t);
35+
data = port_malloc(bitmap_bytes, false);
36+
if (data == NULL) {
37+
m_malloc_fail(bitmap_bytes);
38+
} else {
39+
memset(data, 0x00, bitmap_bytes);
40+
}
3541
self->data_alloc = true;
3642
}
3743
self->data = data;
@@ -64,7 +70,7 @@ void common_hal_displayio_bitmap_construct_from_buffer(displayio_bitmap_t *self,
6470

6571
void common_hal_displayio_bitmap_deinit(displayio_bitmap_t *self) {
6672
if (self->data_alloc) {
67-
gc_free(self->data);
73+
port_free(self->data);
6874
}
6975
self->data = NULL;
7076
}

0 commit comments

Comments
 (0)