Re: gtk_tree_model_get() malloc/free question
- From: Evan Martin <martine cs washington edu>
- To: Mike <maddoc en com>
- Cc: Gtk Mailing List <gtk-app-devel-list gnome org>
- Subject: Re: gtk_tree_model_get() malloc/free question
- Date: Sun, 22 Dec 2002 23:10:59 -0800
On Sun, Dec 22, 2002 at 09:44:11PM -0500, Mike wrote:
But I'm not sure that tells me if I need to g_malloc "place_string_here"
and free it when I'm done or if I'm going to be passed a copy of the
string that I need to free afterwards or if I'm passed a copy of the
pointer that I ignore when I'm done with it. I've tried it by both
allocating memory and freeing it and by just passing it a pointer and
both *seem* to work so I'm not real clear on how I should handle it.
You're passing in a pointer to a gchar* (a gchar**), so it's actually
changing your variable. If you did something like this:
char *foo = g_malloc(...);
gtk_tree_model_get(..., &foo, ...);
// at this point foo no longer points to the allocated memory.
If the function were the sort that expected a preallocated buffer, it
would take a pointer to the buffer as an argument: a plain char*.
--
Evan Martin
martine cs washington edu
http://neugierig.org
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]