diff options
author | Damien George <damien.p.george@gmail.com> | 2014-10-23 12:02:00 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-10-23 12:02:00 +0100 |
commit | 37378f8a9d2b358fdde0f3451d816b7f506846cc (patch) | |
tree | 3d009e47661b41c5406143d7b47a5c85ea082246 /py/gc.c | |
parent | f5d69794a86f7647de3f3b3efd282ed288b1cba6 (diff) |
py: Clean up edge cases of malloc/realloc/free.
Diffstat (limited to 'py/gc.c')
-rw-r--r-- | py/gc.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -546,6 +546,12 @@ void *gc_realloc(void *ptr_in, mp_uint_t n_bytes) { return gc_alloc(n_bytes, false); } + // check for pure free + if (n_bytes == 0) { + gc_free(ptr_in); + return NULL; + } + mp_uint_t ptr = (mp_uint_t)ptr_in; // sanity check the ptr |