summaryrefslogtreecommitdiff
path: root/examples/usercmodule/cppexample/micropython.cmake
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2023-11-03 14:19:55 +1100
committerDamien George <damien@micropython.org>2023-11-03 16:03:18 +1100
commitb6a977848407a4ced45d118cf926bd915cc89dfb (patch)
tree372814eb7f8234ecc5ffc3a7112ad830e69784d9 /examples/usercmodule/cppexample/micropython.cmake
parentc85db05244ef6185fbb3c218c508ddd179830942 (diff)
py/misc: Change sizeof to offsetof for variable-length alloc.
This fixes the case where e.g. struct foo_t { mp_obj_t x; uint16_t y; char buf[]; }; will have `sizeof(struct foo_t)==8`, but `offsetof(struct foo_t, buf)==6`. When computing the size to allocate for `m_new_obj_var` we need to use offsetof to avoid over-allocating. This is important especially when it might cause it to spill over into another GC block. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'examples/usercmodule/cppexample/micropython.cmake')
0 files changed, 0 insertions, 0 deletions