mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 09:50:15 +01:00
map: Add mp_map_dump() (#ifdef'ed) to be handy when debugging maps.
This commit is contained in:
14
py/map.c
14
py/map.c
@@ -243,3 +243,17 @@ void mp_set_clear(mp_set_t *set) {
|
||||
set->used = 0;
|
||||
set->table = NULL;
|
||||
}
|
||||
|
||||
#if DEBUG_PRINT
|
||||
void mp_map_dump(mp_map_t *map) {
|
||||
for (int i = 0; i < map->alloc; i++) {
|
||||
if (map->table[i].key != NULL) {
|
||||
mp_obj_print(map->table[i].key, PRINT_REPR);
|
||||
} else {
|
||||
printf("(nil)");
|
||||
}
|
||||
printf(": %p\n", map->table[i].value);
|
||||
}
|
||||
printf("---\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user