PageRenderTime 25ms CodeModel.GetById 18ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/src/wrappers/glib/partially-implemented/glib_string_chunks.e

http://github.com/tybor/Liberty
Specman e | 104 lines | 7 code | 32 blank | 65 comment | 0 complexity | 670b432a4b099ab72b93dd042f85832a MD5 | raw file
  1indexing
  2	copyright: "(C) 2005 Paolo Redaelli "
  3	license: "LGPL v2 or later"
  4	date: "$Date:$"
  5	revision: "$REvision:$"
  6
  7class GLIB_STRING_CHUNKS
  8-- 	Prev 	Up 	Home 	GLib Reference Manual 	Next
  9-- Top  |  Description
 10-- String Chunks
 11
 12-- String Chunks %G รข€”%@ efficient storage of groups of strings.
 13	
 14-- Synopsis
 15
 16-- #include <glib.h>
 17
 18
 19--             GStringChunk;
 20-- GStringChunk* g_string_chunk_new            (gsize size);
 21-- gchar*      g_string_chunk_insert           (GStringChunk *chunk,
 22--                                              const gchar *string);
 23-- gchar*      g_string_chunk_insert_const     (GStringChunk *chunk,
 24--                                              const gchar *string);
 25-- gchar*      g_string_chunk_insert_len       (GStringChunk *chunk,
 26--                                              const gchar *string,
 27--                                              gssize len);
 28-- void        g_string_chunk_free             (GStringChunk *chunk);
 29
 30-- Description
 31
 32-- String chunks are used to store groups of strings. Memory is allocated in blocks, and as strings are added to the GStringChunk they are copied into the next free position in a block. When a block is full a new block is allocated.
 33
 34-- When storing a large number of strings, string chunks are more efficient than using g_strdup() since fewer calls to malloc() are needed, and less memory is wasted in memory allocation overheads.
 35
 36-- By adding strings with g_string_chunk_insert_const() it is also possible to remove duplicates.
 37
 38-- To create a new GStringChunk use g_string_chunk_new().
 39
 40-- To add strings to a GStringChunk use g_string_chunk_insert().
 41
 42-- To add strings to a GStringChunk, but without duplicating strings which are already in the GStringChunk, use g_string_chunk_insert_const().
 43
 44-- To free the entire GStringChunk use g_string_chunk_free(). It is not possible to free individual strings.
 45-- Details
 46-- GStringChunk
 47
 48-- typedef struct _GStringChunk GStringChunk;
 49
 50-- An opaque data structure representing String Chunks. It should only be accessed by using the following functions.
 51-- g_string_chunk_new ()
 52
 53-- GStringChunk* g_string_chunk_new            (gsize size);
 54
 55-- Creates a new GStringChunk.
 56-- size : 	the default size of the blocks of memory which are allocated to store the strings. If a particular string is larger than this default size, a larger block of memory will be allocated for it.
 57-- Returns : 	a new GStringChunk.
 58-- g_string_chunk_insert ()
 59
 60-- gchar*      g_string_chunk_insert           (GStringChunk *chunk,
 61--                                              const gchar *string);
 62
 63-- Adds a copy of string to the GStringChunk. It returns a pointer to the new copy of the string in the GStringChunk. The characters in the string can be changed, if necessary, though you should not change anything after the end of the string.
 64
 65-- Unlike g_string_chunk_insert_const(), this function does not check for duplicates. Also strings added with g_string_chunk_insert() will not be searched by g_string_chunk_insert_const() when looking for duplicates.
 66-- chunk : 	a GStringChunk.
 67-- string : 	the string to add.
 68-- Returns : 	a pointer to the copy of string within the GStringChunk.
 69-- g_string_chunk_insert_const ()
 70
 71-- gchar*      g_string_chunk_insert_const     (GStringChunk *chunk,
 72--                                              const gchar *string);
 73
 74-- 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().
 75
 76-- 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.
 77
 78-- 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.
 79-- chunk : 	a GStringChunk.
 80-- string : 	the string to add.
 81-- Returns : 	a pointer to the new or existing copy of string within the GStringChunk.
 82-- g_string_chunk_insert_len ()
 83
 84-- gchar*      g_string_chunk_insert_len       (GStringChunk *chunk,
 85--                                              const gchar *string,
 86--                                              gssize len);
 87
 88-- Adds a copy of the first len bytes of string to the GStringChunk. The copy is nul-terminated.
 89
 90-- The characters in the string can be changed, if necessary, though you should not change anything after the end of the string.
 91
 92-- chunk : 	a GStringChunk
 93-- string : 	bytes to insert
 94-- len : 	number of bytes of string to insert, or -1 to insert a nul-terminated string.
 95-- Returns : 	a pointer to the copy of string within the GStringChunk
 96
 97-- Since 2.4
 98-- g_string_chunk_free ()
 99
100-- void        g_string_chunk_free             (GStringChunk *chunk);
101
102-- 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.
103-- chunk : 	a GStringChunk.
104end