Added g_hash_table_contains for glib < 2.32

This commit is contained in:
James Booth
2014-05-22 20:02:19 +01:00
parent ce8f574444
commit 6dbcc03543
2 changed files with 11 additions and 0 deletions

View File

@@ -81,12 +81,21 @@ p_list_free_full(GList *items, GDestroyNotify free_func)
gboolean
p_hash_table_add(GHashTable *hash_table, gpointer key)
{
// doesn't handle when key exists, but value == NULL
gpointer found = g_hash_table_lookup(hash_table, key);
g_hash_table_replace(hash_table, key, key);
return (found == NULL);
}
gboolean
p_hash_table_contains(GHashTable *hash_table, gconstpointer key)
{
// doesn't handle when key exists, but value == NULL
gpointer found = g_hash_table_lookup(hash_table, key);
return (found != NULL);
}
gboolean
create_dir(char *name)
{