summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-11-26 23:39:25 +1100
committerDamien George <damien.p.george@gmail.com>2017-12-11 13:49:09 +1100
commitab750ee2fb6329eb7b0b06ff44a0d0d152ba32b7 (patch)
tree21c4d632345a33093dd3c74d3351e76f1a94d526
parent6df7b2f2fee71e231927511d4baf58ff86eb7983 (diff)
extmod/modure: Convert alloca() to use new scoped allocation API.
-rw-r--r--extmod/modure.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/extmod/modure.c b/extmod/modure.c
index 78de4706d..d0180881d 100644
--- a/extmod/modure.c
+++ b/extmod/modure.c
@@ -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);