extmod/modure: Convert alloca() to use new scoped allocation API.
This commit is contained in:
parent
6df7b2f2fe
commit
ab750ee2fb
|
@ -144,7 +144,7 @@ STATIC mp_obj_t re_split(size_t n_args, const mp_obj_t *args) {
|
|||
}
|
||||
|
||||
mp_obj_t retval = mp_obj_new_list(0, NULL);
|
||||
const char **caps = alloca(caps_num * sizeof(char*));
|
||||
const char **caps = mp_local_alloc(caps_num * sizeof(char*));
|
||||
while (true) {
|
||||
// cast is a workaround for a bug in msvc: it treats const char** as a const pointer instead of a pointer to pointer to const char
|
||||
memset((char**)caps, 0, caps_num * sizeof(char*));
|
||||
|
@ -165,6 +165,7 @@ STATIC mp_obj_t re_split(size_t n_args, const mp_obj_t *args) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
mp_local_free(caps);
|
||||
|
||||
mp_obj_t s = mp_obj_new_str_of_type(str_type, (const byte*)subj.begin, subj.end - subj.begin);
|
||||
mp_obj_list_append(retval, s);
|
||||
|
|
Loading…
Reference in New Issue