diff options
author | youngman <yman.jung@samsung.com> | 2016-02-29 15:37:48 +0900 |
---|---|---|
committer | youngman <yman.jung@samsung.com> | 2016-02-29 15:37:48 +0900 |
commit | 02988ece4f56b47d3fe2c9add3225bc558ebef8b (patch) | |
tree | de059f43a2145f98c5b4ff6ab20d8f2f2d3fb6ca /lib/icl-state.c | |
parent | 49e7cda30fb0088b3f173677ee5b739917a401a1 (diff) | |
download | iotcon-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>
Diffstat (limited to 'lib/icl-state.c')
-rw-r--r-- | lib/icl-state.c | 69 |
1 files changed, 6 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); } |