Fix FC when cloning representation accepted/tizen/common/20151222.101824 accepted/tizen/mobile/20151211.054737 accepted/tizen/tv/20151211.061852 accepted/tizen/wearable/20151211.060632 submit/tizen/20151211.022950 submit/tizen_common/20151211.023048
authorsung.goo.kim <sung.goo.kim@samsung.com>
Thu, 10 Dec 2015 05:27:17 +0000 (14:27 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Thu, 10 Dec 2015 11:45:38 +0000 (20:45 +0900)
Change-Id: I39c75f9ac794984ee65242cc9a43e1918c9b283f

lib/icl-representation.c

index 0325ea3..a8acb9f 100644 (file)
@@ -384,8 +384,6 @@ API int iotcon_representation_clone(const iotcon_representation_h src,
        int ret;
        GList *node;
        iotcon_resource_types_h list;
-       iotcon_state_h ori_state;
-       iotcon_state_h cloned_state = NULL;
        iotcon_representation_h cloned_repr, copied_repr;
 
        RETV_IF(NULL == src, IOTCON_ERROR_INVALID_PARAMETER);
@@ -418,35 +416,26 @@ API int iotcon_representation_clone(const iotcon_representation_h src,
                cloned_repr->res_types = list;
        }
 
-       for (node = g_list_first(src->children); node; node = node->next) {
-               ret = iotcon_representation_clone((iotcon_representation_h)node->data,
-                               &copied_repr);
-               if (IOTCON_ERROR_NONE != ret) {
-                       ERR("iotcon_representation_clone(child) Fail(%d)", ret);
-                       iotcon_representation_destroy(cloned_repr);
-                       return ret;
+       if (src->children) {
+               for (node = g_list_first(src->children); node; node = node->next) {
+                       ret = iotcon_representation_clone((iotcon_representation_h)node->data,
+                                       &copied_repr);
+                       if (IOTCON_ERROR_NONE != ret) {
+                               ERR("iotcon_representation_clone(child) Fail(%d)", ret);
+                               iotcon_representation_destroy(cloned_repr);
+                               return ret;
+                       }
+                       cloned_repr->children = g_list_append(cloned_repr->children, copied_repr);
                }
-               cloned_repr->children = g_list_append(cloned_repr->children, copied_repr);
        }
 
-       ori_state = src->state;
-       if (ori_state->hash_table) {
-               ret = iotcon_state_create(&cloned_state);
-               if (IOTCON_ERROR_NONE != ret) {
-                       ERR("iotcon_state_create() Fail");
-                       iotcon_representation_destroy(cloned_repr);
-                       return ret;
-               }
-               g_hash_table_foreach(ori_state->hash_table, (GHFunc)icl_state_clone_foreach,
-                               cloned_state);
-               ret = iotcon_representation_set_state(cloned_repr, cloned_state);
+       if (src->state) {
+               ret = iotcon_state_clone(src->state, &cloned_repr->state);
                if (IOTCON_ERROR_NONE != ret) {
-                       ERR("iotcon_representation_set_state() Fail");
-                       iotcon_state_destroy(cloned_state);
+                       ERR("iotcon_state_clone() Fail(%d)", ret);
                        iotcon_representation_destroy(cloned_repr);
                        return ret;
                }
-               iotcon_state_destroy(cloned_state);
        }
 
        *dest = cloned_repr;