Fix memory leaks

This commit is contained in:
Jaime Thomas 2008-12-09 02:38:04 +00:00
parent 32640312d9
commit 48f67e3844
3 changed files with 40 additions and 17 deletions

View File

@ -15,6 +15,9 @@ int ecdb_burn_project_init(Ecdb_Burn_Project *proj);
int ecdb_erase_project_init(Ecdb_Erase_Project *proj);
static void ecdb_burn_progress_handler(void *data, void *buffer,
unsigned int nbyte);
void ecdb_sources_list_free(void *data);
void ecdb_tracks_list_free(void *data);
Ecdb_Burn_Project *
ecdb_burn_project_new(void)
@ -89,6 +92,8 @@ ecdb_burn_project(Ecdb_Burn_Project *proj)
data->proj = ECDB_PROJECT(proj);
data->sources = ecore_list_new();
data->tracks = ecore_list_new();
ecore_list_free_cb_set(data->sources, ecdb_sources_list_free);
ecore_list_free_cb_set(data->tracks, ecdb_tracks_list_free);
if (proj->burn_mode != BURN_AUDIO)
padding = 300*1024;
@ -104,6 +109,11 @@ ecdb_burn_project(Ecdb_Burn_Project *proj)
if (!source)
{
printf("Failed to add any files to burn disc!\n");
burn_session_free(data->session);
burn_disc_free(data->disc);
ecore_list_destroy(data->sources);
ecore_list_destroy(data->tracks);
FREE(data);
return ECDB_ERROR_IMAGE_CREATE;
}
@ -111,6 +121,11 @@ ecdb_burn_project(Ecdb_Burn_Project *proj)
{
printf("Error: Cannot attach source object to track "
"object!\n");
burn_session_free(data->session);
burn_disc_free(data->disc);
ecore_list_destroy(data->sources);
ecore_list_destroy(data->tracks);
FREE(data);
return ECDB_ERROR_SOURCE_ATTACH;
}
@ -135,6 +150,12 @@ ecdb_burn_project(Ecdb_Burn_Project *proj)
{
printf("Error: Failed to find a suitable write mode for "
"disc!\n");
burn_session_free(data->session);
burn_disc_free(data->disc);
burn_write_opts_free(opts);
ecore_list_destroy(data->sources);
ecore_list_destroy(data->tracks);
FREE(proj);
return ECDB_ERROR_WRITE_MODE;
}
@ -232,21 +253,10 @@ int
ecdb_burn_finished(void *data, int type, void *event)
{
Burn_Data *proj;
BurnTrack *track;
BurnSource *source;
proj = data;
ecore_list_first(proj->sources);
ecore_list_first(proj->tracks);
printf("Freeing source and tracks\n");
while ((source = ecore_list_remove(proj->sources)))
{
burn_source_free(source);
track = ecore_list_remove(proj->tracks);
burn_track_free(track);
}
ecore_list_destroy(proj->sources);
ecore_list_destroy(proj->tracks);
@ -271,6 +281,19 @@ ecdb_burn_finished(void *data, int type, void *event)
}
FREE(proj);
/* To be removed from here at some point */
ecdb_gui_burn_image_cleanup();
return TRUE;
}
void
ecdb_sources_list_free(void *data)
{
burn_source_free(data);
}
void
ecdb_tracks_list_free(void *data)
{
burn_track_free(data);
}

View File

@ -47,8 +47,8 @@ ecdb_source_destroy(Ecdb_Source *src)
child = src->children[i];
ecdb_source_destroy(child);
}
free(src);
FREE(src->children);
FREE(src);
}
void

View File

@ -38,8 +38,8 @@ ecdb_project_type_set(Ecdb_Project *proj, unsigned int t)
int
ecdb_shutdown(void *data, int type, void *event)
{
if (em->drives)
ecore_list_destroy(em->drives);
if (em->drives) ecore_list_destroy(em->drives);
if (em->dnd_candidates) ecore_list_destroy(em->dnd_candidates);
free(em);
if (!ecore_file_recursive_rm("/tmp/ecdb"))