Skip to content

Commit

Permalink
map: Add mp_map_dump() (#ifdef'ed) to be handy when debugging maps.
Browse files Browse the repository at this point in the history
  • Loading branch information
pfalcon committed Apr 5, 2014
1 parent c393684 commit e3f58c8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions py/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions py/obj.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ 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);
void mp_map_dump(mp_map_t *map);

// Underlying set implementation (not set object)

Expand Down

0 comments on commit e3f58c8

Please sign in to comment.