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

@@ -71,7 +71,7 @@ STATIC void mp_obj_attrtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
}
mp_obj_t mp_obj_new_attrtuple(const qstr *fields, size_t n, const mp_obj_t *items) {
mp_obj_tuple_t *o = mp_obj_malloc_var(mp_obj_tuple_t, mp_obj_t, n + 1, &mp_type_attrtuple);
mp_obj_tuple_t *o = mp_obj_malloc_var(mp_obj_tuple_t, items, mp_obj_t, n + 1, &mp_type_attrtuple);
o->len = n;
for (size_t i = 0; i < n; i++) {
o->items[i] = items[i];