Free memory allocated by bitmap obj
This commit is contained in:
parent
07e83674c9
commit
aa423cc1c6
@ -50,6 +50,9 @@ void common_hal_displayio_bitmap_construct_from_buffer(displayio_bitmap_t *self,
|
|||||||
self->stride = stride(width, bits_per_value);
|
self->stride = stride(width, bits_per_value);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
data = m_malloc(self->stride * height * sizeof(uint32_t), false);
|
data = m_malloc(self->stride * height * sizeof(uint32_t), false);
|
||||||
|
self->data_alloc = true;
|
||||||
|
} else {
|
||||||
|
self->data_alloc = false;
|
||||||
}
|
}
|
||||||
self->data = data;
|
self->data = data;
|
||||||
self->read_only = read_only;
|
self->read_only = read_only;
|
||||||
@ -80,6 +83,9 @@ void common_hal_displayio_bitmap_construct_from_buffer(displayio_bitmap_t *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_displayio_bitmap_deinit(displayio_bitmap_t *self) {
|
void common_hal_displayio_bitmap_deinit(displayio_bitmap_t *self) {
|
||||||
|
if (self->data_alloc) {
|
||||||
|
m_free(self->data);
|
||||||
|
}
|
||||||
self->data = NULL;
|
self->data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@ typedef struct {
|
|||||||
displayio_area_t dirty_area;
|
displayio_area_t dirty_area;
|
||||||
uint16_t bitmask;
|
uint16_t bitmask;
|
||||||
bool read_only;
|
bool read_only;
|
||||||
|
bool data_alloc; // did bitmap allocate data or someone else
|
||||||
} displayio_bitmap_t;
|
} displayio_bitmap_t;
|
||||||
|
|
||||||
void displayio_bitmap_finish_refresh(displayio_bitmap_t *self);
|
void displayio_bitmap_finish_refresh(displayio_bitmap_t *self);
|
||||||
|
Loading…
Reference in New Issue
Block a user