Re: GSList and g_filename_from_uri free memory problem
- From: "Gaurav Jain" <gaurav anywhere gmail com>
- To: Colossus <colossus 3000 it>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: GSList and g_filename_from_uri free memory problem
- Date: Thu, 23 Feb 2006 15:39:19 +0530
Ok, I understood the matter. Let me explain my problem now:
I'm adding drag and drop to my app. To retrieve the content
of the selection dropped into the window of my app I use
gtk_selection_data_get_uris. The problem is that I get the filename
like this: file:///home/gt/GTA%20 and so on. So I use
g_filename_from_uri to convert the filename but this function
allocates memory that I must free. Since the user can drag and drop
more than one file ( you noticed the while loop in the code ? ) when
later I issue g_free ( filename ) only the last pointer will be freed
and the others ?
All your "filenames" can be retrieved and freed by looping through the list:
Something like:
GSList *next_ptr = Files_to_Add;
while (next_ptr != NULL)
{
g_free(next_ptr->data); //this frees the filenames
next_ptr = g_slist_next(next_ptr);
}
g_slist_free(Files_to_Add); //this frees the list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]