Skip to content

Commit

Permalink
py/malloc: Provide a proper malloc-based implementation of realloc_ext.
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgeorge committed Feb 23, 2016
1 parent d6c558c commit e9d1a94
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion py/malloc.c
Expand Up @@ -59,7 +59,16 @@
#define realloc(ptr, n) gc_realloc(ptr, n, true)
#define realloc_ext(ptr, n, mv) gc_realloc(ptr, n, mv)
#else
#define realloc_ext(ptr, n, mv) realloc(ptr, n)
STATIC void *realloc_ext(void *ptr, size_t n_bytes, bool allow_move) {
if (allow_move) {
return realloc(ptr, n_bytes);
} else {
// We are asked to resize, but without moving the memory region pointed to
// by ptr. Unless the underlying memory manager has special provision for
// this behaviour there is nothing we can do except fail to resize.
return NULL;
}
}
#endif // MICROPY_ENABLE_GC

void *m_malloc(size_t num_bytes) {
Expand Down

0 comments on commit e9d1a94

Please sign in to comment.