diff options
author | Jonathan Beck | 2009-10-11 12:14:22 +0200 |
---|---|---|
committer | Jonathan Beck | 2009-10-11 12:14:22 +0200 |
commit | 5a7a91d4eb2263d2c9fd63d51bce9a4738b072d9 (patch) | |
tree | d571396540d0e9ec1cad8bef150eddd8a8e82f56 /src/plist.c | |
parent | f8ba9f02e363e01b34381d945987b6cbefecfe97 (diff) | |
download | libplist-5a7a91d4eb2263d2c9fd63d51bce9a4738b072d9.tar.gz libplist-5a7a91d4eb2263d2c9fd63d51bce9a4738b072d9.tar.bz2 |
Fix dict iteration.
Diffstat (limited to 'src/plist.c')
-rw-r--r-- | src/plist.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/plist.c b/src/plist.c index b723517..5ef3144 100644 --- a/src/plist.c +++ b/src/plist.c @@ -264,24 +264,33 @@ void plist_dict_new_iter(plist_t node, plist_dict_iter *iter) { if (iter && *iter == NULL) { *iter = malloc(sizeof(uint32_t)); - *(uint32_t*)*iter = 0; + *((uint32_t*)(*iter)) = 0; } return; } void plist_dict_next_item(plist_t node, plist_dict_iter iter, char **key, plist_t *val) { - if (node && PLIST_DICT == plist_get_node_type(node) && *(uint32_t*)iter < g_node_n_children(node) / 2) { + uint32_t* iter_int = (uint32_t*) iter; + + if (key) { + *key = NULL; + } + if (val) { + *val = NULL; + } + + if (node && PLIST_DICT == plist_get_node_type(node) && *iter_int < g_node_n_children(node)) { if (key) { - plist_get_key_val((plist_t)g_node_nth_child(node, 2 * (*(uint32_t*)iter)), key); + plist_get_key_val((plist_t)g_node_nth_child(node, *iter_int), key); } if (val) { - *val = (plist_t) g_node_nth_child(node, 2 * (*(uint32_t*)iter) + 1); + *val = (plist_t) g_node_nth_child(node, *iter_int + 1); } - *(uint32_t*)iter += 2; + *iter_int += 2; } return; } |