From 20632e4d3f580b989fa14f58b72896e2cfdeb34b Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Tue, 11 Feb 2014 17:21:03 +0200 Subject: [PATCH] stm: Provide malloc()/realloc()/free(), as forwarding to gc_*() functions. Note: none of these functions are used by STM port, so they're provided to have parity with pre gc refactor status quo, and in case they will be needed in the future by some extension writers. --- stm/mpconfigport.h | 8 ++++++++ stm/std.h | 4 ---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/stm/mpconfigport.h b/stm/mpconfigport.h index fd7af29d27..1d79243f9b 100644 --- a/stm/mpconfigport.h +++ b/stm/mpconfigport.h @@ -21,6 +21,14 @@ typedef float machine_float_t; machine_float_t machine_sqrt(machine_float_t x); +// There is no classical C heap in bare-metal ports, only Python +// garbage-collected heap. For completeness, emulate C heap via +// GC heap. Note that MicroPython core never uses malloc() and friends, +// so these defines are mostly to help extension module writers. +#define malloc gc_alloc +#define free gc_free +#define realloc gc_realloc + // board specific definitions // choose 1 of these boards diff --git a/stm/std.h b/stm/std.h index a2bf706176..843ddd8270 100644 --- a/stm/std.h +++ b/stm/std.h @@ -2,10 +2,6 @@ typedef unsigned int size_t; void __assert_func(void); -void *malloc(size_t n); -void free(void *ptr); -void *realloc(void *ptr, size_t n); - void *memcpy(void *dest, const void *src, size_t n); void *memmove(void *dest, const void *src, size_t n); void *memset(void *s, int c, size_t n);