summaryrefslogtreecommitdiff
path: root/py/gc.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-02-07 17:24:10 +0000
committerDamien George <damien.p.george@gmail.com>2015-02-07 17:24:10 +0000
commite1e359ff59d6bbf09441cc1f3965be63f1046182 (patch)
treec7c05b27f535ebf52fe52fcea9e7fb0b07f18e28 /py/gc.c
parent8785645a952c03315dbf93667b5f7c7eec49762f (diff)
py: Put mp_sys_path, mp_sys_argv and gc_collected in mp_state_ctx_t.
Without mp_sys_path and mp_sys_argv in the root pointer section of the state, their memory was being incorrectly collected by GC.
Diffstat (limited to 'py/gc.c')
-rw-r--r--py/gc.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/py/gc.c b/py/gc.c
index 121e50b78..86db78f84 100644
--- a/py/gc.c
+++ b/py/gc.c
@@ -222,13 +222,9 @@ STATIC void gc_deal_with_stack_overflow(void) {
}
}
-#if MICROPY_PY_GC_COLLECT_RETVAL
-uint gc_collected;
-#endif
-
STATIC void gc_sweep(void) {
#if MICROPY_PY_GC_COLLECT_RETVAL
- gc_collected = 0;
+ MP_STATE_MEM(gc_collected) = 0;
#endif
// free unmarked heads and their tails
int free_tail = 0;
@@ -253,7 +249,7 @@ STATIC void gc_sweep(void) {
#endif
free_tail = 1;
#if MICROPY_PY_GC_COLLECT_RETVAL
- gc_collected++;
+ MP_STATE_MEM(gc_collected)++;
#endif
// fall through to free the head