diff --git a/py/map.c b/py/map.c index 9f919e06ae..2bae8b28d7 100644 --- a/py/map.c +++ b/py/map.c @@ -40,6 +40,17 @@ mp_map_t *mp_map_new(int n) { return map; } +// Differentiate from mp_map_clear() - semantics is different +void mp_map_deinit(mp_map_t *map) { + m_del(mp_map_elem_t, map->table, map->alloc); + map->used = map->alloc = 0; +} + +void mp_map_free(mp_map_t *map) { + mp_map_deinit(map); + m_del_obj(mp_map_t, map); +} + void mp_map_clear(mp_map_t *map) { map->used = 0; map->all_keys_are_qstrs = 1; diff --git a/py/map.h b/py/map.h index 2db0ac3ebc..7acb5a98a7 100644 --- a/py/map.h +++ b/py/map.h @@ -28,6 +28,8 @@ typedef enum _mp_map_lookup_kind_t { int get_doubling_prime_greater_or_equal_to(int x); void mp_map_init(mp_map_t *map, int n); mp_map_t *mp_map_new(int n); +void mp_map_deinit(mp_map_t *map); +void mp_map_free(mp_map_t *map); mp_map_elem_t* mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t lookup_kind); void mp_map_clear(mp_map_t *map);