g_slist_delete_link() don't free data.
This patch add to free data.
Change-Id: I86f3647eccb58282b0340281e18e709f7cada4f8
Signed-off-by: Changgyu Choi <changyu.choi@samsung.com>
*/
link = g_slist_find_custom(filter->list,
(gconstpointer)node, __compare_func);
- if (link)
+ if (link) {
+ _pkgmgrinfo_node_destroy(link->data);
filter->list = g_slist_delete_link(filter->list, link);
+ }
filter->list = g_slist_append(filter->list, (gpointer)node);
return PMINFO_R_OK;
*/
link = g_slist_find_custom(filter->list,
(gconstpointer)node, __compare_func);
- if (link)
+ if (link) {
+ _pkgmgrinfo_node_destroy(link->data);
filter->list = g_slist_delete_link(filter->list, link);
+ }
filter->list = g_slist_append(filter->list, (gpointer)node);
return PMINFO_R_OK;
node->value = strdup(value);
link = g_slist_find_custom(filter->list,
(gconstpointer)node, __compare_func);
- if (link)
+ if (link) {
+ _pkgmgrinfo_node_destroy(link->data);
filter->list = g_slist_delete_link(filter->list, link);
+ }
filter->list = g_slist_append(filter->list, (gpointer)node);
break;
case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
ptr = (pkgmgrinfo_node_x *)link->data;
strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
_LOGI("Previous value is %s\n", prev);
+ _pkgmgrinfo_node_destroy(ptr);
filter->list = g_slist_delete_link(filter->list, link);
ret = snprintf(temp, PKG_STRING_LEN_MAX - 1,
"%s,%s", prev, value);
node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
link = g_slist_find_custom(filter->list,
(gconstpointer)node, __compare_func);
- if (link)
+ if (link) {
+ _pkgmgrinfo_node_destroy(link->data);
filter->list = g_slist_delete_link(filter->list, link);
+ }
filter->list = g_slist_append(filter->list, (gpointer)node);
break;
}
return 1;
}
-static void __destroy_each_node(gpointer data, gpointer user_data)
-{
- ret_if(data == NULL);
- pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)data;
- if (node->value) {
- free(node->value);
- node->value = NULL;
- }
- if (node->key) {
- free(node->key);
- node->key = NULL;
- }
- free(node);
- node = NULL;
-}
-
static void __destroy_metadata_node(gpointer data)
{
pkgmgrinfo_metadata_node_x *node = (pkgmgrinfo_metadata_node_x *)data;
retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
- if (filter->list) {
- g_slist_foreach(filter->list, __destroy_each_node, NULL);
- g_slist_free(filter->list);
- }
+ if (filter->list)
+ g_slist_free_full(filter->list,
+ (GDestroyNotify)_pkgmgrinfo_node_destroy);
- g_slist_free_full(filter->list_metadata, __destroy_metadata_node);
+ if (filter->list_metadata)
+ g_slist_free_full(filter->list_metadata,
+ __destroy_metadata_node);
free(filter);
/*If API is called multiple times for same property, we should override the previous values.
Last value set will be used for filtering.*/
link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
- if (link)
+ if (link) {
+ _pkgmgrinfo_node_destroy(link->data);
filter->list = g_slist_delete_link(filter->list, link);
+ }
filter->list = g_slist_append(filter->list, (gpointer)node);
return PMINFO_R_OK;
/*If API is called multiple times for same property, we should override the previous values.
Last value set will be used for filtering.*/
link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
- if (link)
+ if (link) {
+ _pkgmgrinfo_node_destroy(link->data);
filter->list = g_slist_delete_link(filter->list, link);
+ }
filter->list = g_slist_append(filter->list, (gpointer)node);
return PMINFO_R_OK;
/*If API is called multiple times for same property, we should override the previous values.
Last value set will be used for filtering.*/
link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
- if (link)
+ if (link) {
+ _pkgmgrinfo_node_destroy(link->data);
filter->list = g_slist_delete_link(filter->list, link);
+ }
filter->list = g_slist_append(filter->list, (gpointer)node);
return PMINFO_R_OK;
return prop;
}
+void _pkgmgrinfo_node_destroy(pkgmgrinfo_node_x *node)
+{
+ if (node == NULL)
+ return;
+
+ free(node->value);
+ free(node->key);
+ free(node);
+}
+
API int __get_filter_condition(gpointer data, uid_t uid, char **condition, GList **params)
{
pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)data;
pkgmgrinfo_pkginfo_filter_prop_range _pminfo_pkginfo_convert_to_prop_range(const char *property);
+void _pkgmgrinfo_node_destroy(pkgmgrinfo_node_x *node);
+
int _check_create_cert_db(void);
void _save_column_int(sqlite3_stmt *stmt, int idx, int *i);
void _save_column_str(sqlite3_stmt *stmt, int idx, char **str);