diff options
author | Damien George <damien.p.george@gmail.com> | 2015-02-07 17:24:10 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-02-07 17:24:10 +0000 |
commit | e1e359ff59d6bbf09441cc1f3965be63f1046182 (patch) | |
tree | c7c05b27f535ebf52fe52fcea9e7fb0b07f18e28 /py/mpstate.h | |
parent | 8785645a952c03315dbf93667b5f7c7eec49762f (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/mpstate.h')
-rw-r--r-- | py/mpstate.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/py/mpstate.h b/py/mpstate.h index 10a5db819..a2366df7f 100644 --- a/py/mpstate.h +++ b/py/mpstate.h @@ -32,7 +32,7 @@ #include "py/misc.h" #include "py/nlr.h" #include "py/obj.h" -#include "py/objlist.h" // in case port needs mp_obj_list_t in root pointers +#include "py/objlist.h" #include "py/objexcept.h" // This file contains structures defining the state of the Micro Python @@ -66,6 +66,10 @@ typedef struct _mp_state_mem_t { uint16_t gc_auto_collect_enabled; mp_uint_t gc_last_free_atb_index; + + #if MICROPY_PY_GC_COLLECT_RETVAL + mp_uint_t gc_collected; + #endif } mp_state_mem_t; // This structure hold runtime and VM information. It includes a section @@ -106,6 +110,10 @@ typedef struct _mp_state_vm_t { // dictionary for the __main__ module mp_obj_dict_t dict_main; + // these two lists must be initialised per port, after the call to mp_init + mp_obj_list_t mp_sys_path_obj; + mp_obj_list_t mp_sys_argv_obj; + // dictionary for overridden builtins #if MICROPY_CAN_OVERRIDE_BUILTINS mp_obj_dict_t *mp_module_builtins_override_dict; |