summaryrefslogtreecommitdiffstatshomepage
path: root/stm/malloc0.c
diff options
context:
space:
mode:
authorDamien <damien.p.george@gmail.com>2013-10-21 23:46:04 +0100
committerDamien <damien.p.george@gmail.com>2013-10-21 23:46:04 +0100
commit3f69aca2e23c9479320b9de545eae1d3d8983d35 (patch)
tree169c0a479165ba8e18d7b20ccdcf472c7a556576 /stm/malloc0.c
parentdcced92c265ba67d467251cf8cacac427ec5951c (diff)
downloadmicropython-3f69aca2e23c9479320b9de545eae1d3d8983d35.tar.gz
micropython-3f69aca2e23c9479320b9de545eae1d3d8983d35.zip
Make stm use garbage collector.
Diffstat (limited to 'stm/malloc0.c')
-rw-r--r--stm/malloc0.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/stm/malloc0.c b/stm/malloc0.c
index fc0267911d..686dfbf4be 100644
--- a/stm/malloc0.c
+++ b/stm/malloc0.c
@@ -1,6 +1,9 @@
#include <stdint.h>
#include "std.h"
+#include "mpyconfig.h"
+#include "gc.h"
+#if 0
static uint32_t mem = 0;
void *malloc(size_t n) {
@@ -20,6 +23,12 @@ void *malloc(size_t n) {
void free(void *ptr) {
}
+void *realloc(void *ptr, size_t n) {
+ return malloc(n);
+}
+
+#endif
+
void *calloc(size_t sz, size_t n) {
char *ptr = malloc(sz * n);
for (int i = 0; i < sz * n; i++) {
@@ -28,8 +37,15 @@ void *calloc(size_t sz, size_t n) {
return ptr;
}
+void *malloc(size_t n) {
+ return gc_alloc(n);
+}
+
+void free(void *ptr) {
+}
+
void *realloc(void *ptr, size_t n) {
- return malloc(n);
+ return gc_realloc(ptr, n);
}
void __assert_func() {