aboutsummaryrefslogtreecommitdiffstats
path: root/src/sticker.c
diff options
context:
space:
mode:
authorEric Wollesen <ericw@xmtp.net>2009-03-11 17:03:01 -0600
committerEric Wollesen <ericw@xmtp.net>2009-03-11 17:03:01 -0600
commite2dc3c948ff43fbc7ed0dc5bedf207d139293a97 (patch)
tree328f6f4615be055cc9f709d2d4746d57041451ce /src/sticker.c
parentce6ef89f26d8243e863c9a5a419f91db27e3d6f4 (diff)
downloadmpd-e2dc3c948ff43fbc7ed0dc5bedf207d139293a97.tar.gz
mpd-e2dc3c948ff43fbc7ed0dc5bedf207d139293a97.tar.xz
mpd-e2dc3c948ff43fbc7ed0dc5bedf207d139293a97.zip
Move from the opaque GPtrArray to GHashTable for sticker lists.
Diffstat (limited to 'src/sticker.c')
-rw-r--r--src/sticker.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/sticker.c b/src/sticker.c
index f27df7cf7..750f752af 100644
--- a/src/sticker.c
+++ b/src/sticker.c
@@ -189,15 +189,14 @@ sticker_load_value(const char *type, const char *uri, const char *name)
return value;
}
-GList *
+GHashTable *
sticker_list_values(const char *type, const char *uri)
{
int ret;
char *name, *value;
- GPtrArray *arr;
- GList *list;
+ GHashTable *hash;
- list = NULL;
+ hash = NULL;
assert(type != NULL);
assert(uri != NULL);
@@ -223,12 +222,14 @@ sticker_list_values(const char *type, const char *uri)
ret = sqlite3_step(sticker_stmt_list);
switch (ret) {
case SQLITE_ROW:
+ if (!hash)
+ hash = g_hash_table_new_full(g_str_hash,
+ g_str_equal,
+ (GDestroyNotify)g_free,
+ (GDestroyNotify)g_free);
name = g_strdup((const char*)sqlite3_column_text(sticker_stmt_list, 0));
value = g_strdup((const char*)sqlite3_column_text(sticker_stmt_list, 1));
- arr = g_ptr_array_new();
- g_ptr_array_add(arr, name);
- g_ptr_array_add(arr, value);
- list = g_list_prepend(list, arr);
+ g_hash_table_insert(hash, name, value);
break;
case SQLITE_DONE:
break;
@@ -242,12 +243,10 @@ sticker_list_values(const char *type, const char *uri)
}
} while (ret != SQLITE_DONE);
- list = g_list_reverse(list);
-
sqlite3_reset(sticker_stmt_list);
sqlite3_clear_bindings(sticker_stmt_list);
- return list;
+ return hash;
}
static bool