diff options
author | Damien George <damien.p.george@gmail.com> | 2018-07-09 14:40:02 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2018-07-09 14:40:02 +1000 |
commit | fcf621b066142cc221e5357f54e8156b1cb8c7fd (patch) | |
tree | a2f42acf7954d407c06267c4dcc6ca5b4c7ba98b /py/malloc.c | |
parent | 9c8141f07e034983fe7aa37b3940afbd565730a3 (diff) |
py/malloc: Give a compile warning if using finaliser without GC.
Fixes issue #3844.
Diffstat (limited to 'py/malloc.c')
-rw-r--r-- | py/malloc.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/py/malloc.c b/py/malloc.c index ba5c952f3..f8ed1487a 100644 --- a/py/malloc.c +++ b/py/malloc.c @@ -62,6 +62,13 @@ #define realloc(ptr, n) gc_realloc(ptr, n, true) #define realloc_ext(ptr, n, mv) gc_realloc(ptr, n, mv) #else + +// GC is disabled. Use system malloc/realloc/free. + +#if MICROPY_ENABLE_FINALISER +#error MICROPY_ENABLE_FINALISER requires MICROPY_ENABLE_GC +#endif + STATIC void *realloc_ext(void *ptr, size_t n_bytes, bool allow_move) { if (allow_move) { return realloc(ptr, n_bytes); @@ -72,6 +79,7 @@ STATIC void *realloc_ext(void *ptr, size_t n_bytes, bool allow_move) { return NULL; } } + #endif // MICROPY_ENABLE_GC void *m_malloc(size_t num_bytes) { |