summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs/src')
-rw-r--r--libglusterfs/src/dict.c26
-rw-r--r--libglusterfs/src/dict.h1
-rw-r--r--libglusterfs/src/gfdb/gfdb_data_store.h1
-rw-r--r--libglusterfs/src/gfdb/gfdb_sqlite3.h1
4 files changed, 27 insertions, 2 deletions
diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c
index 31867588def..81db64dfd40 100644
--- a/libglusterfs/src/dict.c
+++ b/libglusterfs/src/dict.c
@@ -2156,6 +2156,32 @@ err:
return ret;
}
+int
+dict_add_dynstr_with_alloc (dict_t *this, char *key, char *str)
+{
+ data_t *data = NULL;
+ int ret = 0;
+ char *alloc_str = NULL;
+
+ alloc_str = gf_strdup (str);
+ if (!alloc_str)
+ goto out;
+
+ data = data_from_dynstr (alloc_str);
+ if (!data) {
+ GF_FREE (alloc_str);
+ ret = -EINVAL;
+ goto out;
+ }
+
+ ret = dict_add (this, key, data);
+ if (ret < 0)
+ data_destroy (data);
+
+out:
+ return ret;
+}
+
/*
for malloced strings we should do a free instead of GF_FREE
*/
diff --git a/libglusterfs/src/dict.h b/libglusterfs/src/dict.h
index a4c1815d06a..a1a4c85f711 100644
--- a/libglusterfs/src/dict.h
+++ b/libglusterfs/src/dict.h
@@ -244,6 +244,7 @@ GF_MUST_CHECK int dict_set_str (dict_t *this, char *key, char *str);
GF_MUST_CHECK int dict_set_dynmstr (dict_t *this, char *key, char *str);
GF_MUST_CHECK int dict_set_dynstr (dict_t *this, char *key, char *str);
GF_MUST_CHECK int dict_set_dynstr_with_alloc (dict_t *this, char *key, const char *str);
+GF_MUST_CHECK int dict_add_dynstr_with_alloc (dict_t *this, char *key, char *str);
GF_MUST_CHECK int dict_get_str (dict_t *this, char *key, char **str);
GF_MUST_CHECK int dict_get_str_boolean (dict_t *this, char *key, int default_val);
diff --git a/libglusterfs/src/gfdb/gfdb_data_store.h b/libglusterfs/src/gfdb/gfdb_data_store.h
index 1212c2b3fe1..ffe590b84bd 100644
--- a/libglusterfs/src/gfdb/gfdb_data_store.h
+++ b/libglusterfs/src/gfdb/gfdb_data_store.h
@@ -26,7 +26,6 @@
#include "gfdb_data_store_types.h"
#include "gfdb_sqlite3.h"
-
/* GFDB Connection Node:
* ~~~~~~~~~~~~~~~~~~~~
* Represents the connection to the database while using libgfdb
diff --git a/libglusterfs/src/gfdb/gfdb_sqlite3.h b/libglusterfs/src/gfdb/gfdb_sqlite3.h
index b0c4b2b5fdd..04bfde7fa38 100644
--- a/libglusterfs/src/gfdb/gfdb_sqlite3.h
+++ b/libglusterfs/src/gfdb/gfdb_sqlite3.h
@@ -143,7 +143,6 @@ do {\
};\
} while (0)
-
#define GF_SQLITE3_SET_PRAGMA(sqlite3_config_str, param_key, format, value,\
ret, error)\
do {\