[PATCH 4/4] icmap: Add map copy function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Jan Friesse <jfriesse@xxxxxxxxxx>
---
 exec/icmap.c             |   34 ++++++++++++++++++++++++++++++++++
 include/corosync/icmap.h |    5 +++++
 2 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/exec/icmap.c b/exec/icmap.c
index 83cdfb4..cfc49ca 100644
--- a/exec/icmap.c
+++ b/exec/icmap.c
@@ -1280,3 +1280,37 @@ int icmap_is_key_ro(const char *key_name)
 	return (CS_FALSE);
 
 }
+
+cs_error_t icmap_copy_map(icmap_map_t dst_map, const icmap_map_t src_map)
+{
+	icmap_iter_t iter;
+	size_t value_len;
+	icmap_value_types_t value_type;
+	const char *key_name;
+	cs_error_t err;
+	void *value;
+
+	iter = icmap_iter_init_r(src_map, NULL);
+	if (iter == NULL) {
+		return (CS_ERR_NO_MEMORY);
+	}
+
+	err = CS_OK;
+
+	while ((key_name = icmap_iter_next(iter, &value_len, &value_type)) != NULL) {
+		err = icmap_get_ref_r(src_map, key_name, &value, &value_len, &value_type);
+		if (err != CS_OK) {
+			goto exit_iter_finalize;
+		}
+
+		err = icmap_set_r(dst_map, key_name, value, value_len, value_type);
+		if (err != CS_OK) {
+			goto exit_iter_finalize;
+		}
+	}
+
+exit_iter_finalize:
+	icmap_iter_finalize(iter);
+
+	return (err);
+}
diff --git a/include/corosync/icmap.h b/include/corosync/icmap.h
index 91dfd59..8026c88 100644
--- a/include/corosync/icmap.h
+++ b/include/corosync/icmap.h
@@ -368,6 +368,11 @@ extern int icmap_is_key_ro(const char *key_name);
  */
 extern void icmap_convert_name_to_valid_name(char *key_name);
 
+/*
+ * Copy content of src_map icmap to dst_map icmap.
+ */
+extern cs_error_t icmap_copy_map(icmap_map_t dst_map, const icmap_map_t src_map);
+
 #ifdef __cplusplus
 }
 #endif
-- 
1.7.1

_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss




[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux