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.
This commit is contained in:
Darin Adler
2000-08-17 21:37:18 +00:00
parent f17ed7ee26
commit 4010a5acb2
14 changed files with 204 additions and 26 deletions

View File

@@ -1925,7 +1925,7 @@ gchar* g_string_chunk_insert_const (GStringChunk *chunk,
*/
GString* g_string_new (const gchar *init);
GString* g_string_sized_new (guint dfl_size);
void g_string_free (GString *string,
gchar* g_string_free (GString *string,
gboolean free_segment);
gboolean g_string_equal (const GString *v,
const GString *v2);
@@ -1988,7 +1988,7 @@ GArray* g_array_sized_new (gboolean zero_terminated,
gboolean clear,
guint element_size,
guint reserved_size);
void g_array_free (GArray *array,
gchar* g_array_free (GArray *array,
gboolean free_segment);
GArray* g_array_append_vals (GArray *array,
gconstpointer data,
@@ -2015,7 +2015,7 @@ GArray* g_array_remove_index_fast (GArray *array,
#define g_ptr_array_index(array,index) (array->pdata)[index]
GPtrArray* g_ptr_array_new (void);
GPtrArray* g_ptr_array_sized_new (guint reserved_size);
void g_ptr_array_free (GPtrArray *array,
gpointer* g_ptr_array_free (GPtrArray *array,
gboolean free_seg);
void g_ptr_array_set_size (GPtrArray *array,
gint length);
@@ -2036,7 +2036,7 @@ void g_ptr_array_add (GPtrArray *array,
GByteArray* g_byte_array_new (void);
GByteArray* g_byte_array_sized_new (guint reserved_size);
void g_byte_array_free (GByteArray *array,
guint8* g_byte_array_free (GByteArray *array,
gboolean free_segment);
GByteArray* g_byte_array_append (GByteArray *array,
const guint8 *data,