summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2010-10-11 13:56:57 +0200
committerSebastien Helleu <flashcode@flashtux.org>2010-10-11 13:56:57 +0200
commitf32e18c717520e3482b1a4155ff4e804da7aecbb (patch)
tree8be6e042cebaadab4236ead19374637d1704176f /src/core
parentb9d6c5c5a04b2fa06306e0b626b2318bcb797d21 (diff)
downloadweechat-f32e18c717520e3482b1a4155ff4e804da7aecbb.zip
Add function "hashtable_has_key" in WeeChat and plugin API
Diffstat (limited to 'src/core')
-rw-r--r--src/core/wee-hashtable.c10
-rw-r--r--src/core/wee-hashtable.h1
2 files changed, 11 insertions, 0 deletions
diff --git a/src/core/wee-hashtable.c b/src/core/wee-hashtable.c
index a8f5b2018..e8e8f1e83 100644
--- a/src/core/wee-hashtable.c
+++ b/src/core/wee-hashtable.c
@@ -375,6 +375,16 @@ hashtable_get (struct t_hashtable *hashtable, const void *key)
}
/*
+ * hashtable_has_key: return 1 if key is in hashtable, otherwise 0
+ */
+
+int
+hashtable_has_key (struct t_hashtable *hashtable, const void *key)
+{
+ return (hashtable_get_item (hashtable, key, NULL) != NULL) ? 1 : 0;
+}
+
+/*
* hashtable_map: call a function on all hashtable entries
*/
diff --git a/src/core/wee-hashtable.h b/src/core/wee-hashtable.h
index a8fe253cf..ef045889b 100644
--- a/src/core/wee-hashtable.h
+++ b/src/core/wee-hashtable.h
@@ -113,6 +113,7 @@ extern int hashtable_set_with_size (struct t_hashtable *hashtable,
extern int hashtable_set (struct t_hashtable *hashtable, void *key,
void *value);
extern void *hashtable_get (struct t_hashtable *hashtable, const void *key);
+extern int hashtable_has_key (struct t_hashtable *hashtable, const void *key);
extern void hashtable_map (struct t_hashtable *hashtable,
t_hashtable_map *callback_map,
void *callback_map_data);