Skip to content

Commit

Permalink
[appsync] Use correct function to release dynamic memory
Browse files Browse the repository at this point in the history
There is data obtained via g_key_file_get_string() that is released
with free().

Use g_free() instead.

Also use a helper callback function with expected argument types
when releasing a list of elements.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Jul 7, 2016
1 parent 21400d5 commit 2abea95
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/usb_moded-appsync.c
Expand Up @@ -55,21 +55,26 @@ static int no_dbus = 0;
#endif /* APP_SYNC_DBUS */


static void free_elem(gpointer aptr)
static void free_elem(struct list_elem *elem)
{
struct list_elem *elem = aptr;
free(elem->name);
free(elem->launch);
free(elem->mode);
g_free(elem->name);
g_free(elem->launch);
g_free(elem->mode);
free(elem);
}

static void free_elem_cb(gpointer elem, gpointer user_data)
{
(void)user_data;
free_elem(elem);
}

void free_appsync_list(void)
{
if( sync_list != 0 )
{
/*g_list_free_full(sync_list, free_elem); */
g_list_foreach (sync_list, (GFunc) free_elem, NULL);
g_list_foreach (sync_list, free_elem_cb, NULL);
g_list_free (sync_list);
sync_list = 0;
log_debug("Appsync list freed\n");
Expand Down

0 comments on commit 2abea95

Please sign in to comment.