Blame SOURCES/0123-lib-add-a-clone-function-for-map_string_t.patch

0c9110
From 4790093363f4bb625905bdb3a81a62c598d41405 Mon Sep 17 00:00:00 2001
0c9110
From: Jakub Filak <jfilak@redhat.com>
0c9110
Date: Fri, 19 Dec 2014 00:16:44 +0100
0c9110
Subject: [LIBREPORT PATCH 123/124] lib: add a clone function for map_string_t
0c9110
0c9110
Related: #1140224, #1174833
0c9110
0c9110
Signed-off-by: Jakub Filak <jfilak@redhat.com>
0c9110
---
0c9110
 src/include/libreport_types.h |  2 ++
0c9110
 src/lib/abrt_types.c          | 17 +++++++++++++++++
0c9110
 2 files changed, 19 insertions(+)
0c9110
0c9110
diff --git a/src/include/libreport_types.h b/src/include/libreport_types.h
0c9110
index 41ed5d7..2c60972 100644
0c9110
--- a/src/include/libreport_types.h
0c9110
+++ b/src/include/libreport_types.h
0c9110
@@ -33,6 +33,8 @@ typedef GHashTable map_string_t;
0c9110
 map_string_t *new_map_string(void);
0c9110
 #define free_map_string libreport_free_map_string
0c9110
 void free_map_string(map_string_t *ms);
0c9110
+#define clone_map_string libreport_clone_map_string
0c9110
+map_string_t *clone_map_string(map_string_t *ms);
0c9110
 #define size_map_string libreport_size_map_string
0c9110
 static inline
0c9110
 unsigned size_map_string(map_string_t *ms)
0c9110
diff --git a/src/lib/abrt_types.c b/src/lib/abrt_types.c
0c9110
index 1ad4acc..fddaa46 100644
0c9110
--- a/src/lib/abrt_types.c
0c9110
+++ b/src/lib/abrt_types.c
0c9110
@@ -29,6 +29,23 @@ void free_map_string(map_string_t *ms)
0c9110
         g_hash_table_destroy(ms);
0c9110
 }
0c9110
 
0c9110
+map_string_t *clone_map_string(map_string_t *ms)
0c9110
+{
0c9110
+    if (ms == NULL)
0c9110
+        return NULL;
0c9110
+
0c9110
+    map_string_t *clone = new_map_string();
0c9110
+
0c9110
+    const char *key;
0c9110
+    const char *value;
0c9110
+    map_string_iter_t iter;
0c9110
+    init_map_string_iter(&iter, ms);
0c9110
+    while(next_map_string_iter(&iter, &key, &value))
0c9110
+        insert_map_string(clone, xstrdup(key), xstrdup(value));
0c9110
+
0c9110
+    return clone;
0c9110
+}
0c9110
+
0c9110
 const char *get_map_string_item_or_empty(map_string_t *ms, const char *key)
0c9110
 {
0c9110
     const char *v = (const char*)g_hash_table_lookup(ms, key);
0c9110
-- 
0c9110
1.8.3.1
0c9110