String Chunks
String Chunks — efficient storage of groups of strings
|
|
Includes
#include <gmodule.h>
Functions
g_string_chunk_insert_const ()
gchar *
g_string_chunk_insert_const (GStringChunk *chunk,
const gchar *string);
Adds a copy of string
to the GStringChunk, unless the same
string has already been added to the GStringChunk with
g_string_chunk_insert_const().
This function is useful if you need to copy a large number
of strings but do not want to waste space storing duplicates.
But you must remember that there may be several pointers to
the same string, and so any changes made to the strings
should be done very carefully.
Note that g_string_chunk_insert_const() will not return a
pointer to a string added with g_string_chunk_insert(), even
if they do match.
Returns
a pointer to the new or existing copy of string
within the GStringChunk
g_string_chunk_insert_len ()
gchar *
g_string_chunk_insert_len (GStringChunk *chunk,
const gchar *string,
gssize len);
Adds a copy of the first len
bytes of string
to the GStringChunk.
The copy is nul-terminated.
Since this function does not stop at nul bytes, it is the caller's
responsibility to ensure that string
has at least len
addressable
bytes.
The characters in the returned string can be changed, if necessary,
though you should not change anything after the end of the string.
Returns
a pointer to the copy of string
within the GStringChunk
Since: 2.4
g_string_chunk_clear ()
void
g_string_chunk_clear (GStringChunk *chunk);
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
g_string_chunk_free ()
void
g_string_chunk_free (GStringChunk *chunk);
Frees all memory allocated by the GStringChunk.
After calling g_string_chunk_free() it is not safe to
access any of the strings which were contained within it.
Types and Values
GStringChunk
typedef struct _GStringChunk GStringChunk;
An opaque data structure representing String Chunks.
It should only be accessed by using the following functions.