summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/dict.c
diff options
context:
space:
mode:
authorPranith Kumar K <pranithk@gluster.com>2011-09-07 21:26:41 +0530
committerVijay Bellur <vijay@gluster.com>2011-09-14 05:36:06 -0700
commit3bea46c1f232a4480e57ac482f92f7673af7034f (patch)
treea8f180fa1ad4ffb1fce6ee5c83ffb3161c003d42 /libglusterfs/src/dict.c
parent78dee45ef829296dbcb4cf28e06feb8e25458c91 (diff)
dict: add reset function which empties the dict
Change-Id: I267c81a129197534fb318671eafb76e144a15c8c BUG: 2458 Reviewed-on: http://review.gluster.com/402 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'libglusterfs/src/dict.c')
-rw-r--r--libglusterfs/src/dict.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c
index 5a07ba6b76a..35a6c94f069 100644
--- a/libglusterfs/src/dict.c
+++ b/libglusterfs/src/dict.c
@@ -1230,6 +1230,15 @@ _copy (dict_t *unused,
dict_set ((dict_t *)newdict, key, (value));
}
+static void
+_remove (dict_t *dict,
+ char *key,
+ data_t *value,
+ void *unused)
+{
+ dict_del ((dict_t *)dict, key);
+}
+
dict_t *
dict_copy (dict_t *dict,
@@ -1248,6 +1257,20 @@ dict_copy (dict_t *dict,
return new;
}
+int
+dict_reset (dict_t *dict)
+{
+ int32_t ret = -1;
+ if (!dict) {
+ gf_log_callingfn ("dict", GF_LOG_WARNING, "dict is NULL");
+ goto out;
+ }
+ dict_foreach (dict, _remove, NULL);
+ ret = 0;
+out:
+ return ret;
+}
+
dict_t *
dict_copy_with_ref (dict_t *dict,
dict_t *new)