py/obj: Change sizeof to offsetof in mp_obj_malloc_var macro.

Following b6a9778484, to properly calculate
the size of the variable-length allocation.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2024-02-16 11:41:28 +11:00
parent 9242e3d16d
commit 2423493774
16 changed files with 25 additions and 25 deletions

View File

@@ -113,7 +113,7 @@ mp_int_t imageHeight(microbit_image_obj_t * p_image) {
}
STATIC greyscale_t *greyscale_new(mp_int_t w, mp_int_t h) {
greyscale_t *result = mp_obj_malloc_var(greyscale_t, uint8_t, (w*h+1)>>1, &microbit_image_type);
greyscale_t *result = mp_obj_malloc_var(greyscale_t, byte_data, uint8_t, (w*h+1)>>1, &microbit_image_type);
result->five = 0;
result->width = w;
result->height = h;