summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
Diffstat (limited to 'py')
-rwxr-xr-xpy/gc.c4
-rw-r--r--py/gc.h2
2 files changed, 6 insertions, 0 deletions
diff --git a/py/gc.c b/py/gc.c
index 5e631f5ed..fef67f61b 100755
--- a/py/gc.c
+++ b/py/gc.c
@@ -464,6 +464,10 @@ void gc_info(gc_info_t *info) {
GC_EXIT();
}
+bool gc_alloc_possible(void) {
+ return MP_STATE_MEM(gc_pool_start) != 0;
+}
+
// We place long lived objects at the end of the heap rather than the start. This reduces
// fragmentation by localizing the heap churn to one portion of memory (the start of the heap.)
void *gc_alloc(size_t n_bytes, bool has_finaliser, bool long_lived) {
diff --git a/py/gc.h b/py/gc.h
index cd63ba94c..2a0811f4e 100644
--- a/py/gc.h
+++ b/py/gc.h
@@ -58,6 +58,8 @@ void gc_collect_ptr(void *ptr);
void gc_collect_root(void **ptrs, size_t len);
void gc_collect_end(void);
+// Is the gc heap available?
+bool gc_alloc_possible(void);
void *gc_alloc(size_t n_bytes, bool has_finaliser, bool long_lived);
// Use this function to sweep the whole heap and run all finalisers