3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Apache License, Version 2.0 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #include "data-adapter/common.h"
19 #include "data-adapter/common_internal.h"
20 #include "utility/sync_util.h"
23 #define EXPORT_API __attribute__ ((visibility("default")))
26 #ifndef SYNC_AGENT_LOG
28 #define LOG_TAG "AF_DACI"
32 * ==========================================================
33 * Structure Memory Free
34 * ==========================================================
36 void sync_agent_free_memory_folder(sync_agent_da_folder_s * folder, int count)
40 retm_if(folder == NULL, "sync_agent_da_folder_s is NULL !!");
43 for (i = 0; i < count; i++) {
44 SYNC_AGENT_DA_MEMORY_FREE(folder[i].folder_id);
45 SYNC_AGENT_DA_MEMORY_FREE(folder[i].parent_folder_id);
46 SYNC_AGENT_DA_MEMORY_FREE(folder[i].service_id);
47 SYNC_AGENT_DA_MEMORY_FREE(folder[i].access_name);
49 SYNC_AGENT_DA_MEMORY_FREE(folder);
54 void sync_agent_free_memory_item(sync_agent_da_item_s * item, int count)
58 retm_if(item == NULL, "sync_agent_da_item_s is NULL !!");
61 for (i = 0; i < count; i++) {
62 SYNC_AGENT_DA_MEMORY_FREE(item[i].item_id);
63 SYNC_AGENT_DA_MEMORY_FREE(item[i].folder_id);
64 SYNC_AGENT_DA_MEMORY_FREE(item[i].service_id);
65 SYNC_AGENT_DA_MEMORY_FREE(item[i].access_name);
67 SYNC_AGENT_DA_MEMORY_FREE(item);
72 void da_free_memory_config(sync_agent_da_config_s * config, int count)
76 retm_if(config == NULL, "sync_agent_da_config_s is NULL !!");
79 for (i = 0; i < count; i++) {
80 SYNC_AGENT_DA_MEMORY_FREE(config[i].key);
81 SYNC_AGENT_DA_MEMORY_FREE(config[i].value);
82 SYNC_AGENT_DA_MEMORY_FREE(config[i].type);
83 SYNC_AGENT_DA_MEMORY_FREE(config[i].access_name);
85 SYNC_AGENT_DA_MEMORY_FREE(config);
90 void da_free_memory_item_changelog(sync_agent_da_item_changelog_s * item_changelog, int count)
94 retm_if(item_changelog == NULL, "sync_agent_da_item_changelog_s is NULL !!");
97 for (i = 0; i < count; i++) {
98 SYNC_AGENT_DA_MEMORY_FREE(item_changelog[i].item_id);
99 SYNC_AGENT_DA_MEMORY_FREE(item_changelog[i].status);
100 SYNC_AGENT_DA_MEMORY_FREE(item_changelog[i].access_name);
102 SYNC_AGENT_DA_MEMORY_FREE(item_changelog);
107 EXPORT_API void sync_agent_free_memory_last_anchor(sync_agent_da_last_anchor_s * last_anchor, int count)
111 retm_if(last_anchor == NULL, "sync_agent_da_last_anchor_s is NULL !!");
114 for (i = 0; i < count; i++) {
115 SYNC_AGENT_DA_MEMORY_FREE(last_anchor[i].last_anchor_server);
116 SYNC_AGENT_DA_MEMORY_FREE(last_anchor[i].last_anchor_client);
117 SYNC_AGENT_DA_MEMORY_FREE(last_anchor[i].access_name);
119 SYNC_AGENT_DA_MEMORY_FREE(last_anchor);
124 EXPORT_API void sync_agent_free_memory_mapping(sync_agent_da_mapping_s * mapping, int count)
128 retm_if(mapping == NULL, "sync_agent_da_mapping_s is NULL !!");
131 for (i = 0; i < count; i++) {
132 SYNC_AGENT_DA_MEMORY_FREE(mapping[i].luid);
133 SYNC_AGENT_DA_MEMORY_FREE(mapping[i].guid);
134 SYNC_AGENT_DA_MEMORY_FREE(mapping[i].access_name);
136 SYNC_AGENT_DA_MEMORY_FREE(mapping);
141 EXPORT_API void sync_agent_free_memory_item_info(sync_agent_da_item_info_s * item_info, int count)
145 retm_if(item_info == NULL, "sync_agent_da_item_info_s is NULL !!");
148 for (i = 0; i < count; i++) {
149 SYNC_AGENT_DA_MEMORY_FREE(item_info[i].itemId);
150 SYNC_AGENT_DA_MEMORY_FREE(item_info[i].serviceId);
151 SYNC_AGENT_DA_MEMORY_FREE(item_info[i].syncStatus);
153 SYNC_AGENT_DA_MEMORY_FREE(item_info);
158 EXPORT_API void sync_agent_free_memory_id_list(sync_agent_da_id_list_s * id_list)
162 retm_if(id_list == NULL, "sync_agent_da_id_list_s is NULL !!");
165 for (i = 0; i < id_list->count; i++) {
166 SYNC_AGENT_DA_MEMORY_FREE(id_list->id[i]);
168 SYNC_AGENT_DA_MEMORY_FREE(id_list->id);
169 SYNC_AGENT_DA_MEMORY_FREE(id_list);