summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryoungman <yman.jung@samsung.com>2016-02-29 15:37:48 +0900
committeryoungman <yman.jung@samsung.com>2016-02-29 15:37:48 +0900
commit02988ece4f56b47d3fe2c9add3225bc558ebef8b (patch)
treede059f43a2145f98c5b4ff6ab20d8f2f2d3fb6ca
parent49e7cda30fb0088b3f173677ee5b739917a401a1 (diff)
downloadiotcon-02988ece4f56b47d3fe2c9add3225bc558ebef8b.tar.gz
iotcon-02988ece4f56b47d3fe2c9add3225bc558ebef8b.tar.bz2
iotcon-02988ece4f56b47d3fe2c9add3225bc558ebef8b.zip
Modify icl_value_clone()
Change-Id: Iaece289dbf2e0b39e012572b829995812de7343f Signed-off-by: youngman <yman.jung@samsung.com>
-rw-r--r--lib/icl-state.c69
-rw-r--r--lib/icl-value.c6
2 files changed, 12 insertions, 63 deletions
diff --git a/lib/icl-state.c b/lib/icl-state.c
index 5d9d6ee..6a245b2 100644
--- a/lib/icl-state.c
+++ b/lib/icl-state.c
@@ -543,72 +543,15 @@ API int iotcon_state_clone(iotcon_state_h state, iotcon_state_h *state_clone)
void icl_state_clone_foreach(char *key, iotcon_value_h src_val, iotcon_state_h dest_state)
{
FN_CALL;
- int type, ret;
- iotcon_value_h value, copied_val;
- iotcon_list_h child_list, copied_list;
- iotcon_state_h child_state;
- iotcon_state_h copied_state = NULL;
-
- type = src_val->type;
- switch (type) {
- case IOTCON_TYPE_INT:
- case IOTCON_TYPE_BOOL:
- case IOTCON_TYPE_DOUBLE:
- case IOTCON_TYPE_STR:
- case IOTCON_TYPE_BYTE_STR:
- case IOTCON_TYPE_NULL:
- copied_val = icl_value_clone(src_val);
- if (NULL == copied_val) {
- ERR("icl_value_clone() Fail");
- return;
- }
-
- icl_state_set_value(dest_state, key, copied_val);
- break;
- case IOTCON_TYPE_LIST:
- ret = icl_value_get_list(src_val, &child_list);
- if (IOTCON_ERROR_NONE != ret) {
- ERR("icl_value_get_list() Fail(%d)", ret);
- return;
- }
-
- copied_list = icl_list_clone(child_list);
- if (NULL == copied_list) {
- ERR("icl_list_clone() Fail");
- return;
- }
-
- value = icl_value_create_list(copied_list);
- if (NULL == value) {
- ERR("icl_value_create_list() Fail");
- iotcon_list_destroy(copied_list);
- return;
- }
+ iotcon_value_h copied_val;
- icl_state_set_value(dest_state, key, value);
- break;
- case IOTCON_TYPE_STATE:
- ret = icl_value_get_state(src_val, &child_state);
- if (IOTCON_ERROR_NONE != ret) {
- ERR("icl_value_get_state() Fail(%d)", ret);
- return;
- }
-
- g_hash_table_foreach(child_state->hash_table, (GHFunc)icl_state_clone_foreach,
- copied_state);
-
- value = icl_value_create_state(copied_state);
- if (NULL == value) {
- ERR("icl_value_create_state(%p) Fail", copied_state);
- return;
- }
-
- icl_state_set_value(dest_state, key, value);
- break;
- default:
- ERR("Invalid type(%d)", type);
+ copied_val = icl_value_clone(src_val);
+ if (NULL == copied_val) {
+ ERR("icl_value_clone() Fail");
return;
}
+
+ icl_state_set_value(dest_state, key, copied_val);
}
diff --git a/lib/icl-value.c b/lib/icl-value.c
index fd73f29..2366ffe 100644
--- a/lib/icl-value.c
+++ b/lib/icl-value.c
@@ -363,6 +363,12 @@ iotcon_value_h icl_value_clone(iotcon_value_h src)
dest = icl_value_create_byte_str(((icl_val_byte_str_s*)real)->s,
((icl_val_byte_str_s*)real)->len);
break;
+ case IOTCON_TYPE_LIST:
+ dest = icl_value_create_list(((icl_val_list_s*)real)->list);
+ break;
+ case IOTCON_TYPE_STATE:
+ dest = icl_value_create_state(((icl_val_state_s*)real)->state);
+ break;
default:
ERR("Invalid type(%d)", src->type);
break;