Commit 0a3afe44 authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen

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)
parent eaec9bb8
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.
......
......@@ -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
......
......@@ -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)
......
......@@ -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,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment