Skip to content

Commit f32020e

Browse files
committed
py/mpconfig.h: Allow to build without alloca() for ANSI C compliance.
Define MICROPY_NO_ALLOCA=1 and memory will be allocated from heap instead and freed by garbage collection.
1 parent f0fbab7 commit f32020e

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

py/mpconfig.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,16 @@
189189
#define MICROPY_STACKLESS_STRICT (0)
190190
#endif
191191

192+
// Don't use alloca calls. As alloca() is not part of ANSI C, this
193+
// workaround option is provided for compilers lacking this de-facto
194+
// standard function. The way it works is allocating from heap, and
195+
// relying on garbage collection to free it eventually. This is of
196+
// course much less optimal than real alloca().
197+
#if defined(MICROPY_NO_ALLOCA) && MICROPY_NO_ALLOCA
198+
#undef alloca
199+
#define alloca(x) m_malloc(x)
200+
#endif
201+
192202
/*****************************************************************************/
193203
/* Micro Python emitters */
194204

0 commit comments

Comments
 (0)