Add a function for clearing a GStringChunk. (#364608, Matt Barnes)

2006-12-15  Matthias Clasen  <mclasen@redhat.com>

        * glib/glib.symbols:
        * glib/gstring.[hc] (g_string_chunk_clear): Add a function
        for clearing a GStringChunk. (#364608, Matt Barnes)
This commit is contained in:
Matthias Clasen 2006-12-15 22:57:15 +00:00 committed by Matthias Clasen
parent eaec9bb86e
commit 0a3afe448b
4 changed files with 39 additions and 0 deletions

View File

@ -1,5 +1,9 @@
2006-12-15 Matthias Clasen <mclasen@redhat.com>
* glib/glib.symbols:
* glib/gstring.[hc] (g_string_chunk_clear): Add a function
for clearing a GStringChunk. (#364608, Matt Barnes)
* glib/guniprop.c (interval_compare): Avoid a compiler
warning.

View File

@ -1078,6 +1078,7 @@ g_string_ascii_down
g_string_ascii_up
g_string_assign
g_string_chunk_free
g_string_chunk_clear
g_string_chunk_insert
g_string_chunk_insert_const
g_string_chunk_insert_len

View File

@ -162,6 +162,39 @@ g_string_chunk_free (GStringChunk *chunk)
g_free (chunk);
}
/**
* g_string_chunk_clear:
* @chunk: a #GStringChunk
*
* Frees all strings contained within the #GStringChunk.
* After calling g_string_chunk_clear() it is not safe to
* access any of the strings which were contained within it.
*
* Since: 2.14
*/
void
g_string_chunk_clear (GStringChunk *chunk)
{
GSList *tmp_list;
g_return_if_fail (chunk != NULL);
if (chunk->storage_list)
{
for (tmp_list = chunk->storage_list; tmp_list; tmp_list = tmp_list->next)
g_free (tmp_list->data);
g_slist_free (chunk->storage_list);
chunk->storage_list = NULL;
chunk->storage_next = chunk->default_size;
chunk->this_size = chunk->default_size;
}
if (chunk->const_table)
g_hash_table_remove_all (chunk->const_table);
}
gchar*
g_string_chunk_insert (GStringChunk *chunk,
const gchar *string)

View File

@ -47,6 +47,7 @@ struct _GString
*/
GStringChunk* g_string_chunk_new (gsize size);
void g_string_chunk_free (GStringChunk *chunk);
void g_string_chunk_clear (GStringChunk *chunk);
gchar* g_string_chunk_insert (GStringChunk *chunk,
const gchar *string);
gchar* g_string_chunk_insert_len (GStringChunk *chunk,