Skip to content

Commit 20632e4

Browse files
committed
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.
1 parent e7db817 commit 20632e4

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

stm/mpconfigport.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ typedef float machine_float_t;
2121

2222
machine_float_t machine_sqrt(machine_float_t x);
2323

24+
// There is no classical C heap in bare-metal ports, only Python
25+
// garbage-collected heap. For completeness, emulate C heap via
26+
// GC heap. Note that MicroPython core never uses malloc() and friends,
27+
// so these defines are mostly to help extension module writers.
28+
#define malloc gc_alloc
29+
#define free gc_free
30+
#define realloc gc_realloc
31+
2432
// board specific definitions
2533

2634
// choose 1 of these boards

stm/std.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ typedef unsigned int size_t;
22

33
void __assert_func(void);
44

5-
void *malloc(size_t n);
6-
void free(void *ptr);
7-
void *realloc(void *ptr, size_t n);
8-
95
void *memcpy(void *dest, const void *src, size_t n);
106
void *memmove(void *dest, const void *src, size_t n);
117
void *memset(void *s, int c, size_t n);

0 commit comments

Comments
 (0)