summaryrefslogtreecommitdiff
path: root/py/misc.h
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2022-05-04 12:12:11 +1000
committerDamien George <damien@micropython.org>2022-05-05 10:31:50 +1000
commitfca5701f74b784834d1af22d10988a1d0fddddaf (patch)
treef98c1d6c9e1473a13455857af0563760abcd08ec /py/misc.h
parent965747bd97183a85db56e8d79c15c589df87cdd6 (diff)
py/malloc: Introduce m_tracked_calloc, m_tracked_free functions.
Enabled by MICROPY_TRACKED_ALLOC. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py/misc.h')
-rw-r--r--py/misc.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/py/misc.h b/py/misc.h
index e1d27dc7b..d94afd0b0 100644
--- a/py/misc.h
+++ b/py/misc.h
@@ -103,6 +103,13 @@ void m_free(void *ptr);
#endif
NORETURN void m_malloc_fail(size_t num_bytes);
+#if MICROPY_TRACKED_ALLOC
+// These alloc/free functions track the pointers in a linked list so the GC does not reclaim
+// them. They can be used by code that requires traditional C malloc/free semantics.
+void *m_tracked_calloc(size_t nmemb, size_t size);
+void m_tracked_free(void *ptr_in);
+#endif
+
#if MICROPY_MEM_STATS
size_t m_get_total_bytes_allocated(void);
size_t m_get_current_bytes_allocated(void);