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/builtinimport.c | |
parent | 02d830c035aca166d70551e485ccd2d1658189c9 (diff) |
py: Convert all uses of alloca() to use new scoped allocation API.
Diffstat (limited to 'py/builtinimport.c')
-rw-r--r-- | py/builtinimport.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/py/builtinimport.c b/py/builtinimport.c index 9235e946c..2157902c9 100644 --- a/py/builtinimport.c +++ b/py/builtinimport.c @@ -318,7 +318,7 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) { } uint new_mod_l = (mod_len == 0 ? (size_t)(p - this_name) : (size_t)(p - this_name) + 1 + mod_len); - char *new_mod = alloca(new_mod_l); + char *new_mod = mp_local_alloc(new_mod_l); memcpy(new_mod, this_name, p - this_name); if (mod_len != 0) { new_mod[p - this_name] = '.'; @@ -326,9 +326,10 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) { } qstr new_mod_q = qstr_from_strn(new_mod, new_mod_l); + mp_local_free(new_mod); DEBUG_printf("Resolved base name for relative import: '%s'\n", qstr_str(new_mod_q)); module_name = MP_OBJ_NEW_QSTR(new_mod_q); - mod_str = new_mod; + mod_str = qstr_str(new_mod_q); mod_len = new_mod_l; } |