File tree Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,17 @@ mp_map_t *mp_map_new(int n) {
4040 return map ;
4141}
4242
43+ // Differentiate from mp_map_clear() - semantics is different
44+ void mp_map_deinit (mp_map_t * map ) {
45+ m_del (mp_map_elem_t , map -> table , map -> alloc );
46+ map -> used = map -> alloc = 0 ;
47+ }
48+
49+ void mp_map_free (mp_map_t * map ) {
50+ mp_map_deinit (map );
51+ m_del_obj (mp_map_t , map );
52+ }
53+
4354void mp_map_clear (mp_map_t * map ) {
4455 map -> used = 0 ;
4556 map -> all_keys_are_qstrs = 1 ;
Original file line number Diff line number Diff line change @@ -28,6 +28,8 @@ typedef enum _mp_map_lookup_kind_t {
2828int get_doubling_prime_greater_or_equal_to (int x );
2929void mp_map_init (mp_map_t * map , int n );
3030mp_map_t * mp_map_new (int n );
31+ void mp_map_deinit (mp_map_t * map );
32+ void mp_map_free (mp_map_t * map );
3133mp_map_elem_t * mp_map_lookup (mp_map_t * map , mp_obj_t index , mp_map_lookup_kind_t lookup_kind );
3234void mp_map_clear (mp_map_t * map );
3335
Original file line number Diff line number Diff line change @@ -166,6 +166,7 @@ void rt_init(void) {
166166
167167 mp_module_micropython_init ();
168168
169+ // TODO: wastes one mp_code_t structure in mem
169170 next_unique_code_id = 1 ; // 0 indicates "no code"
170171 unique_codes_alloc = 0 ;
171172 unique_codes = NULL ;
@@ -177,6 +178,9 @@ void rt_init(void) {
177178
178179void rt_deinit (void ) {
179180 m_del (mp_code_t , unique_codes , unique_codes_alloc );
181+ mp_map_free (map_globals );
182+ mp_map_deinit (& map_loaded_modules );
183+ mp_map_deinit (& map_builtins );
180184#ifdef WRITE_CODE
181185 if (fp_write_code != NULL ) {
182186 fclose (fp_write_code );
You can’t perform that action at this time.
0 commit comments