allocating mem using glib

2012-09-02 Thread Mostafa Alshrief
hi there, i have a question about allocating/deallocating memory using glib i have created this simple app to demonstrate : http://pastebin.com/kVncSgxh the app creates a simple GSList list and fill it with a data structure of type item_data   at line 65 i use a loop to free mem allocated by

Re: allocating mem using glib

2012-09-02 Thread richard boaz
a few things of note: 1. you're printing the elements after you free the memory, that's not gonna work 2. use (iterator = g_slist_next(iterator)) to increment; do not refer to (iterator-next) directly 3. after you've freed the list data elements, you need to free the list

Re: allocating mem using glib

2012-09-02 Thread Jasper St. Pierre
On Sun, Sep 2, 2012 at 5:00 AM, richard boaz ivor.b...@gmail.com wrote: a few things of note: you're printing the elements after you free the memory, that's not gonna work use (iterator = g_slist_next(iterator)) to increment; do not refer to (iterator-next) directly This is the only one I

Re: allocating mem using glib

2012-09-02 Thread richard boaz
well, i'm a big fan of using the interface methods as opposed to referring to elements directly. this is unlikely to change ever in the future where GSList is concerned, but for me it's a question of practice and following consistent standards. there are certainly other examples where the