if (result_data != NULL) {
result_data_item->result_data = bundle_dup(result_data);
if (result_data_item->result_data == NULL) {
+ free(result_data_item);
LOGE("fail to alloc result_data");
return DATACONTROL_ERROR_OUT_OF_MEMORY;
}
bundle *bulk_data;
data_control_bulk_data_h bulk_data_h = NULL;
bundle_raw *encode_data = NULL;
- int encode_datalen;
+ int encode_datalen = 0;
LOGD("send async ~~~");
ret = DATACONTROL_ERROR_IO_ERROR;
goto out;
}
+ encode_datalen = 0;
+ bundle_free_encoded_rawdata(&encode_data);
}
}
} while (count < TRY_COUNT);
if (count >= TRY_COUNT) {
+ bundle_free(arg_list);
LOGE("unable to launch service: %d", pid);
return DATACONTROL_ERROR_IO_ERROR;
}
{
datacontrol_consumer_request_info temp_request_info;
+ datacontrol_consumer_request_info *data;
+
temp_request_info.request_id = request_id;
GList *list = g_list_find_custom(map_dc->request_info_list, &temp_request_info,
(GCompareFunc)_consumer_request_compare_cb);
- if (list != NULL)
+ if (list != NULL) {
+ data = (datacontrol_consumer_request_info *)list->data;
map_dc->request_info_list = g_list_remove(map_dc->request_info_list, list->data);
+ free(data);
+ }
}
static int __map_handle_cb(int fd, bundle *b, int request_type, int request_id, appsvc_result_val res, void *data)
int result_list_len = 0;
int provider_result = 0;
int value_count = 0;
+ int i;
char **value_list = NULL;
const char *p = NULL;
data_control_bulk_result_data_h bulk_results = NULL;
ret = DATACONTROL_ERROR_INVALID_PARAMETER;
}
+ if (bulk_results)
+ datacontrol_bulk_result_data_destroy(bulk_results);
+
+ if (value_list) {
+ for (i = 0; i < value_count; i++) {
+ if (value_list[i] != NULL)
+ free(value_list[i]);
+ }
+ free(value_list);
+ }
+
return ret;
}
int count = 0;
const int TRY_COUNT = 2;
const struct timespec TRY_SLEEP_TIME = { 0, 1000 * 1000 * 1000 };
+ bundle *send_data;
LOGI("Map Data control request, type: %d, request id: %d", type, request_id);
return DATACONTROL_ERROR_INVALID_PARAMETER;
}
- bundle_add_str(request_data, OSP_K_DATACONTROL_PROTOCOL_VERSION, OSP_V_VERSION_2_1_0_3);
- bundle_add_str(request_data, AUL_K_CALLER_APPID, caller_app_id);
+ send_data = bundle_dup(request_data);
+ if (send_data == NULL) {
+ LOGE("fail to alloc result_data");
+ return DATACONTROL_ERROR_OUT_OF_MEMORY;
+ }
+
+ bundle_add_str(send_data, OSP_K_DATACONTROL_PROTOCOL_VERSION, OSP_V_VERSION_2_1_0_3);
+ bundle_add_str(send_data, AUL_K_CALLER_APPID, caller_app_id);
snprintf(datacontrol_request_operation, MAX_LEN_DATACONTROL_REQ_TYPE, "%d", (int)(type));
- bundle_add_str(request_data, OSP_K_DATACONTROL_REQUEST_TYPE, datacontrol_request_operation);
+ bundle_add_str(send_data, OSP_K_DATACONTROL_REQUEST_TYPE, datacontrol_request_operation);
snprintf(req_id, 32, "%d", request_id);
- bundle_add_str(request_data, OSP_K_REQUEST_ID, req_id);
+ bundle_add_str(send_data, OSP_K_REQUEST_ID, req_id);
LOGI("caller_id %s, app_id %s", caller_app_id, app_id);
datacontrol_socket_info *socket_info = g_hash_table_lookup(__socket_pair_hash, provider->provider_id);
if (socket_info == NULL) {
ret = _request_appsvc_run(caller_app_id, app_id);
- if (ret != DATACONTROL_ERROR_NONE)
+ if (ret != DATACONTROL_ERROR_NONE) {
+ bundle_free(send_data);
return ret;
+ }
socket_info = _add_watch_on_socket_info(caller_app_id, app_id, "consumer", __recv_map_message, data);
- if (socket_info == NULL)
+ if (socket_info == NULL) {
+ bundle_free(send_data);
return DATACONTROL_ERROR_IO_ERROR;
+ }
g_hash_table_insert(__socket_pair_hash, strdup(provider->provider_id), socket_info);
}
LOGI("send data from consumer !!!");
- ret = _datacontrol_send_async(socket_info->socket_fd, request_data, extra_data, type, NULL);
+ ret = _datacontrol_send_async(socket_info->socket_fd, send_data, extra_data, type, NULL);
if (ret != DATACONTROL_ERROR_NONE)
g_hash_table_remove(__socket_pair_hash, provider->provider_id);
else
nanosleep(&TRY_SLEEP_TIME, 0);
} while (ret != DATACONTROL_ERROR_NONE && count < TRY_COUNT);
+ bundle_free(send_data);
return ret;
}
free(provider_info->data_id);
if (provider_info->monitor_id > 0)
g_dbus_connection_signal_unsubscribe(_get_dbus_connection(), provider_info->monitor_id);
- g_list_free(provider_info->cb_list);
+ g_list_free_full(provider_info->cb_list, free);
free(provider_info);
}
}
add_callback_result_cb_info_s find_info;
datacontrol_h provider;
GList *find_list;
+
find_info.callback_id = callback_id;
find_list = g_list_find_custom(__add_callback_result_cb_list, &find_info,
(GCompareFunc)__callback_result_info_compare_cb);
callback_result,
callback_id,
result_cb_info->user_data);
- __add_callback_result_cb_list = g_list_remove_link(__add_callback_result_cb_list, find_list);
- __free_result_cb_info((add_callback_result_cb_info_s *)find_list->data);
+
+ __add_callback_result_cb_list = g_list_remove(__add_callback_result_cb_list, find_list->data);
+ __free_result_cb_info(result_cb_info);
_destroy_datacontrol_h(provider);
} else {
LOGE("add_callback_result_cb_info_s is null");
provider_info_s info;
provider_info_s *target_provider_info;
add_callback_result_cb_info_s result_cb_info;
+ add_callback_result_cb_info_s *tmp;
GList *provider_list = NULL;
GList *callback_list = NULL;
GList *result_cb_list = NULL;
removed_cb_info = (changed_cb_info_s *)callback_list->data;
target_provider_info->cb_list
= g_list_remove(target_provider_info->cb_list, removed_cb_info);
+ free(removed_cb_info);
if (g_list_length(target_provider_info->cb_list) == 0) {
unique_id = g_dbus_connection_get_unique_name(_get_dbus_connection());
return ret;
}
- __changed_provider_list = g_list_remove_link(__changed_provider_list, provider_list);
- __free_provider_info((provider_info_s *)provider_list->data);
+ __changed_provider_list = g_list_remove(__changed_provider_list, target_provider_info);
+ __free_provider_info(target_provider_info);
}
result_cb_info.callback_id = callback_id;
result_cb_list = g_list_find_custom(__add_callback_result_cb_list, &result_cb_info,
(GCompareFunc)__callback_result_info_compare_cb);
if (result_cb_list) {
- __add_callback_result_cb_list = g_list_remove_link(__add_callback_result_cb_list, result_cb_list);
- __free_result_cb_info((add_callback_result_cb_info_s *)result_cb_list->data);
+ tmp = (add_callback_result_cb_info_s *)result_cb_list->data;
+ __add_callback_result_cb_list = g_list_remove(__add_callback_result_cb_list, result_cb_list->data);
+ __free_result_cb_info(tmp);
}
return DATACONTROL_ERROR_NONE;
}
g_bus_unwatch_name(info->monitor_id);
__noti_consumer_app_list = g_list_remove(__noti_consumer_app_list, find_list->data);
+
+ free(info);
LOGI("__free_consumer_info done");
}
+static void __free_bundle_data(gpointer data)
+{
+ if (data) {
+ bundle_free(data);
+ data = NULL;
+ }
+}
+
static void __free_data(gpointer data)
{
if (data) {
static void __initialize_provider(void)
{
int result;
- __request_table = g_hash_table_new_full(g_int_hash, g_int_equal, __free_data, __free_data);
+ __request_table = g_hash_table_new_full(g_int_hash, g_int_equal, __free_data, __free_bundle_data);
__socket_pair_hash = g_hash_table_new_full(g_str_hash, g_str_equal, free, _socket_info_free);
result = __create_consumer_list_db();
if (result != DATACONTROL_ERROR_NONE)
consumer_info,
NULL);
+ if (consumer_info->monitor_id == 0) {
+ LOGE("g_bus_watch_name_on_connection fail");
+
+ free(consumer_info->appid);
+ free(consumer_info->object_path);
+ free(consumer_info->unique_id);
+ free(consumer_info);
+ continue;
+ }
+
LOGI("noti consumer_app_list append %s", consumer_info->object_path);
__noti_consumer_app_list =
g_list_append(__noti_consumer_app_list, consumer_info);
if (key)
free(key);
if (value)
- free(value);
+ bundle_free(value);
return DATACONTROL_ERROR_IO_ERROR;
}
if (provider)
free(provider);
+ if (path)
+ free(path);
return result;
}
err->message);
g_error_free(err);
}
- return DATACONTROL_ERROR_IO_ERROR;
+ result = DATACONTROL_ERROR_IO_ERROR;
+ goto out;
}
out:
{
GList *find_list;
changed_noti_consumer_filter_info_s filter_info;
+ changed_noti_consumer_filter_info_s *temp;
+
filter_info.callback_id = callback_id;
find_list = g_list_find_custom(__noti_consumer_filter_info_list, &filter_info,
(GCompareFunc)__data_changed_filter_cb_info_compare_cb);
if (find_list != NULL) {
+ temp = (changed_noti_consumer_filter_info_s *)find_list->data;
__noti_consumer_filter_info_list = g_list_remove(__noti_consumer_filter_info_list, find_list->data);
+ free(temp);
} else {
LOGE("invalid callback_id : %d", callback_id);
return DATACONTROL_ERROR_INVALID_PARAMETER;
break;
}
out:
- sqlite3_reset(stmt);
- sqlite3_clear_bindings(stmt);
- sqlite3_finalize(stmt);
+ if (stmt) {
+ sqlite3_reset(stmt);
+ sqlite3_clear_bindings(stmt);
+ sqlite3_finalize(stmt);
+ }
return ret;
}
{
datacontrol_consumer_request_info temp_request_info;
+ datacontrol_consumer_request_info *temp_data;
+
temp_request_info.request_id = request_id;
GList *list = g_list_find_custom(sql_dc->request_info_list, &temp_request_info,
(GCompareFunc)_consumer_request_compare_cb);
- if (list != NULL)
+ if (list != NULL) {
+ temp_data = (datacontrol_consumer_request_info *)list->data;
sql_dc->request_info_list = g_list_remove(sql_dc->request_info_list, list->data);
+ free(temp_data);
+ }
}
guint nb;
const char *p = NULL;
int request_id;
- bundle *kb;
+ bundle *kb = NULL;
sql_response_cb_s *sql_dc;
GList *itr;
datacontrol_consumer_request_info *request_info;
!= DATACONTROL_ERROR_NONE)
goto error;
__remove_sql_request_info(request_id, data);
+ bundle_free(kb);
}
}
return TRUE;
error:
if (buf)
free(buf);
+ if (kb)
+ bundle_free(kb);
if (((sql_response_cb_s *)data) != NULL) {
LOGE("g_hash_table_remove");
bundle *bulk_data;
data_control_bulk_data_h bulk_data_h = NULL;
bundle_raw *encode_data = NULL;
- int encode_datalen;
+ int encode_datalen = 0;
LOGD("send async ~~~");
ret = DATACONTROL_ERROR_IO_ERROR;
goto out;
}
+ encode_datalen = 0;
+ bundle_free_encoded_rawdata(&encode_data);
}
}
const int TRY_COUNT = 2;
const struct timespec TRY_SLEEP_TIME = { 0, 1000 * 1000 * 1000 };
char *socket_info_key;
-
+ bundle *send_data;
LOGI("SQL Data control request, type: %d, request id: %d", type, request_id);
return DATACONTROL_ERROR_INVALID_PARAMETER;
}
- bundle_add_str(request_data, OSP_K_DATACONTROL_PROTOCOL_VERSION, OSP_V_VERSION_2_1_0_3);
- bundle_add_str(request_data, AUL_K_CALLER_APPID, caller_app_id);
+ send_data = bundle_dup(request_data);
+ if (send_data == NULL) {
+ LOGE("fail to alloc result_data");
+ return DATACONTROL_ERROR_OUT_OF_MEMORY;
+ }
+
+ bundle_add_str(send_data, OSP_K_DATACONTROL_PROTOCOL_VERSION, OSP_V_VERSION_2_1_0_3);
+ bundle_add_str(send_data, AUL_K_CALLER_APPID, caller_app_id);
snprintf(datacontrol_request_operation, MAX_LEN_DATACONTROL_REQ_TYPE, "%d", (int)(type));
- bundle_add_str(request_data, OSP_K_DATACONTROL_REQUEST_TYPE, datacontrol_request_operation);
+ bundle_add_str(send_data, OSP_K_DATACONTROL_REQUEST_TYPE, datacontrol_request_operation);
snprintf(req_id, 32, "%d", request_id);
- bundle_add_str(request_data, OSP_K_REQUEST_ID, req_id);
+ bundle_add_str(send_data, OSP_K_REQUEST_ID, req_id);
do {
datacontrol_socket_info *socket_info = g_hash_table_lookup(__socket_pair_hash, provider->provider_id);
ret = _request_appsvc_run(caller_app_id, app_id);
if (ret != DATACONTROL_ERROR_NONE) {
LOGE("_request_appsvc_run error !!!");
+ bundle_free(send_data);
return ret;
}
socket_info = _add_watch_on_socket_info(caller_app_id, app_id, "consumer", __consumer_recv_sql_message, response_cb_data);
if (socket_info == NULL) {
LOGE("_get_socket_info error !!!");
+ bundle_free(send_data);
return DATACONTROL_ERROR_IO_ERROR;
}
socket_info_key = strdup(provider->provider_id);
if (socket_info_key == NULL) {
LOGE("Out of memory. can not dup select map file.");
+ bundle_free(send_data);
return DATACONTROL_ERROR_IO_ERROR;
}
g_hash_table_insert(__socket_pair_hash, socket_info_key, socket_info);
}
LOGE("send data from consumer");
- ret = __datacontrol_send_sql_async(socket_info->socket_fd, request_data, extra_data, type, NULL);
+ ret = __datacontrol_send_sql_async(socket_info->socket_fd, send_data, extra_data, type, NULL);
if (ret != DATACONTROL_ERROR_NONE)
g_hash_table_remove(__socket_pair_hash, provider->provider_id);
else
nanosleep(&TRY_SLEEP_TIME, 0);
} while (ret != DATACONTROL_ERROR_NONE && count < TRY_COUNT);
+ bundle_free(send_data);
return ret;
}