diff options
author | Darin Adler <darin@src.gnome.org> | 2000-08-17 21:37:18 +0000 |
---|---|---|
committer | Darin Adler <darin@src.gnome.org> | 2000-08-17 21:37:18 +0000 |
commit | 4010a5acb2be1747e60a0e844a508dbf0f55a149 (patch) | |
tree | 54a40b6b92f6f06b1291c0bf2cc41f66044a2795 /gstring.c | |
parent | f17ed7ee26e447fe6d32201d3bb9c5801dbf4d30 (diff) | |
download | glib-4010a5acb2be1747e60a0e844a508dbf0f55a149.tar.gz |
Return the data left behind. Return the data left behind.
* glib.h:
* garray.c: (g_array_free), (g_ptr_array_free),
(g_byte_array_free): Return the data left behind.
* gstring.c: (g_string_free): Return the data left behind.
Changed the free calls that leave data behind so they
return a pointer to the left-behind data, NULL if told not
to leave anything behind. This makes these calls easier
to use correctly, without any incompatible API change for
callers that don't know about the return value. Of course,
it would be even clearer if the free calls weren't dual-purpose
in the first place.
Diffstat (limited to 'gstring.c')
-rw-r--r-- | gstring.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -251,18 +251,27 @@ g_string_new (const gchar *init) return string; } -void +gchar* g_string_free (GString *string, gboolean free_segment) { + gchar *segment; + g_return_if_fail (string != NULL); if (free_segment) - g_free (string->str); + { + g_free (string->str); + segment = NULL; + } + else + segment = string->str; G_LOCK (string_mem_chunk); g_mem_chunk_free (string_mem_chunk, string); G_UNLOCK (string_mem_chunk); + + return segment; } gboolean |