Skip to content

Commit ab750ee

Browse files
committed
extmod/modure: Convert alloca() to use new scoped allocation API.
1 parent 6df7b2f commit ab750ee

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

extmod/modure.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ STATIC mp_obj_t re_split(size_t n_args, const mp_obj_t *args) {
144144
}
145145

146146
mp_obj_t retval = mp_obj_new_list(0, NULL);
147-
const char **caps = alloca(caps_num * sizeof(char*));
147+
const char **caps = mp_local_alloc(caps_num * sizeof(char*));
148148
while (true) {
149149
// 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
150150
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) {
165165
break;
166166
}
167167
}
168+
mp_local_free(caps);
168169

169170
mp_obj_t s = mp_obj_new_str_of_type(str_type, (const byte*)subj.begin, subj.end - subj.begin);
170171
mp_obj_list_append(retval, s);

0 commit comments

Comments
 (0)