[Adium-devl] g_string_free() and me (aka gaim [17165] doesn't like Adium)

Mark Doliner mark at kingant.net
Sun Sep 10 22:46:01 UTC 2006


On Fri, 8 Sep 2006 18:18:34 -0700, Peter Hosey wrote
> On Sep 8, 2006, at 13:09:50, Evan Schoenberg wrote:
> > The glib we're using definitely claims that g_string_free() returns  
> > a char*, so I'm not sure why this matters.  In fact, I'm mystified.
> 
> So am I. Do I want to know why a “free” function is returning things?

It's actually pretty convenient.  If you pass TRUE in to g_string_free() it
frees the GString struct and the character data.  If you pass in FALSE it only
frees the GString struct and returns the character data.  Here's an example:

static gchar *create_hello_message() {
  GString *str = g_string_new("");

  g_string_append(str, "Hello");
  g_string_append(str, ", world!");

  return g_string_free(str, FALSE);
}




More information about the devel mailing list