summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/dict.c
diff options
context:
space:
mode:
authorKrishnan Parthasarathi <kparthas@redhat.com>2014-04-02 11:36:20 +0530
committerAnand Avati <avati@redhat.com>2014-04-14 09:15:14 -0700
commita9d4d369efc978511e3cb69e5643945710cc9416 (patch)
tree19a8b0da0502de2d486470a921fc6dec45afc100 /libglusterfs/src/dict.c
parent09d2dcac3a238cfe6bde1a7aed06facfa16caf20 (diff)
dict: add dict_set_dynstr_with_alloc
There is an overwhelming no. of instances of the following pattern in glusterd module. ... char *dynstr = gf_strdup (str); if (!dynstr) goto err; ret = dict_set_dynstr (dict, key, dynstr); if (ret) goto err; ... With this changes it would look as below, ret = dict_set_dynstr_with_alloc (dict, key, str); if (ret) goto err; Change-Id: I6a47b1cbab4834badadc48c56d0b5c8c06c6dd4d Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com> Reviewed-on: http://review.gluster.org/7379 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Diffstat (limited to 'libglusterfs/src/dict.c')
-rw-r--r--libglusterfs/src/dict.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c
index 7bc5d57b0..1bed8bf9b 100644
--- a/libglusterfs/src/dict.c
+++ b/libglusterfs/src/dict.c
@@ -2067,6 +2067,23 @@ err:
}
int
+dict_set_dynstr_with_alloc (dict_t *this, char *key, const char *str)
+{
+ char *alloc_str = NULL;
+ int ret = -1;
+
+ alloc_str = gf_strdup (str);
+ if (!alloc_str)
+ return -1;
+
+ ret = dict_set_dynstr (this, key, alloc_str);
+ if (ret)
+ GF_FREE (alloc_str);
+
+ return ret;
+}
+
+int
dict_set_dynstr (dict_t *this, char *key, char *str)
{
data_t * data = NULL;