diff options
author | Benjamin Dauvergne <bdauvergne@entrouvert.com> | 2010-12-01 15:20:48 +0100 |
---|---|---|
committer | Benjamin Dauvergne <bdauvergne@entrouvert.com> | 2010-12-01 15:20:48 +0100 |
commit | f4c6c96836e546a3fd4ce348bd9fe719e5b9d80d (patch) | |
tree | 6a66afe041f123cb828da069ad0fcadaba45c06e /bindings | |
parent | fbf7ad0537e752ac9e4a99943177c158328944e0 (diff) | |
download | lasso-f4c6c96836e546a3fd4ce348bd9fe719e5b9d80d.tar.gz lasso-f4c6c96836e546a3fd4ce348bd9fe719e5b9d80d.tar.xz lasso-f4c6c96836e546a3fd4ce348bd9fe719e5b9d80d.zip |
[bindings perl] change ghashtable interface to not use GHashTableIter
Diffstat (limited to 'bindings')
-rw-r--r-- | bindings/perl/ghashtable_handling.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/bindings/perl/ghashtable_handling.c b/bindings/perl/ghashtable_handling.c index b49ed9f5..541041d8 100644 --- a/bindings/perl/ghashtable_handling.c +++ b/bindings/perl/ghashtable_handling.c @@ -78,6 +78,15 @@ set_hash_of_objects(GHashTable **hash, HV *hv) } } +static void +__ht_foreach_get_hos(gpointer key, gpointer value, gpointer user_data) +{ + HV *hv = user_data; + + (void)hv_store(hv, key, strlen(key), newSVpv(value, 0), 0); +} + + /** * get_hash_of_strings: * @hash: a #GHashTable of strings @@ -85,18 +94,21 @@ set_hash_of_objects(GHashTable **hash, HV *hv) HV* get_hash_of_strings(GHashTable *hash) { - GHashTableIter iter; - gpointer key, value; HV *hv; hv = newHV(); - g_hash_table_iter_init(&iter, hash); - while (g_hash_table_iter_next(&iter, &key, &value)) { - (void)hv_store(hv, key, strlen(key), newSVpv(value, 0), 0); - } + g_hash_table_foreach(hash, __ht_foreach_get_hos, hv); return hv; } +static void +__ht_foreach_get_hoo(gpointer key, gpointer value, gpointer user_data) +{ + HV *hv = user_data; + + (void)hv_store(hv, key, strlen(key), gperl_new_object(value, FALSE), 0); +} + /** * get_hash_of_objects: * @hash: a #GHashTable of objects @@ -104,14 +116,9 @@ get_hash_of_strings(GHashTable *hash) HV* get_hash_of_objects(GHashTable *hash) { - GHashTableIter iter; - gpointer key, value; HV *hv; hv = newHV(); - g_hash_table_iter_init(&iter, hash); - while (g_hash_table_iter_next(&iter, &key, &value)) { - (void)hv_store(hv, key, strlen(key), gperl_new_object(value, FALSE), 0); - } + g_hash_table_foreach(hash, __ht_foreach_get_hos, hv); return hv; } |