diff options
author | Damien George <damien.p.george@gmail.com> | 2017-11-26 23:37:19 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2017-12-11 13:49:09 +1100 |
commit | 1e5a33df413bbd8a8aa5bd880be445c684fc5506 (patch) | |
tree | 38e8bdbe9e64711485909c58458bc44b6a6a34fb /py/vm.c | |
parent | 02d830c035aca166d70551e485ccd2d1658189c9 (diff) |
py: Convert all uses of alloca() to use new scoped allocation API.
Diffstat (limited to 'py/vm.c')
-rw-r--r-- | py/vm.c | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -1108,7 +1108,13 @@ unwind_return: if (code_state->prev != NULL) { mp_obj_t res = *sp; mp_globals_set(code_state->old_globals); - code_state = code_state->prev; + mp_code_state_t *new_code_state = code_state->prev; + #if MICROPY_ENABLE_PYSTACK + // The sizeof in the following statement does not include the size of the variable + // part of the struct. This arg is anyway not used if pystack is enabled. + mp_nonlocal_free(code_state, sizeof(mp_code_state_t)); + #endif + code_state = new_code_state; *code_state->sp = res; goto run_code_state; } @@ -1450,7 +1456,13 @@ unwind_loop: #if MICROPY_STACKLESS } else if (code_state->prev != NULL) { mp_globals_set(code_state->old_globals); - code_state = code_state->prev; + mp_code_state_t *new_code_state = code_state->prev; + #if MICROPY_ENABLE_PYSTACK + // The sizeof in the following statement does not include the size of the variable + // part of the struct. This arg is anyway not used if pystack is enabled. + mp_nonlocal_free(code_state, sizeof(mp_code_state_t)); + #endif + code_state = new_code_state; size_t n_state = mp_decode_uint_value(code_state->fun_bc->bytecode); fastn = &code_state->state[n_state - 1]; exc_stack = (mp_exc_stack_t*)(code_state->state + n_state); |