PageRenderTime 35ms CodeModel.GetById 32ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://github.com/tybor/Liberty
Specman e | 96 lines | 19 code | 25 blank | 52 comment | 0 complexity | bb0ccb2d61f036d01499db7fac9737eb MD5 | raw file
 1indexing
 2	copyright: "(C) 2005 Paolo Redaelli "
 3	license: "LGPL v2 or later"
 4	date: "$Date:$"
 5	revision: "$REvision:$"
 6
 7class G_STRING_CHUNK
 8	-- An efficient storage of groups of strings.
 9	
10	-- String chunks are used to store groups of strings. Memory is
11	-- allocated in blocks, and as strings are added to the
12	-- G_STRING_CHUNK they are copied into the next free position in a
13	-- block. When a block is full a new block is allocated.
14
15	-- When storing a large number of strings, string chunks are more
16	-- efficient than using the C function `g_strdup' since fewer calls
17	-- to `malloc' are needed, and less memory is wasted in memory
18	-- allocation overheads.
19
20	-- By adding strings with `insert_const' it is also possible to
21	-- remove duplicates.
22	
23	-- To add strings to a G_STRING_CHUNK use g_string_chunk_insert().
24	
25	-- To add strings to a G_STRING_CHUNK, but without duplicating
26	-- strings which are already in the G_STRING_CHUNK, use
27	-- g_string_chunk_insert_const().
28
29inherit 
30	C_STRUCT
31	EIFFEL_OWNED
32
33insert 
34	GSTRING_EXTERNALS
35	GSTRING_CHUNK_STRUCT
36	
37creation make, from_external_pointer
38	
39feature
40	make (a_size: NATURAL_32) is
41			-- Creates a new G_STRING_CHUNK, with `a_size' the default
42			-- size of the blocks of memory which are allocated to store
43			-- the strings. If a particular string is larger than this
44			-- default size, a larger block of memory will be allocated
45			-- for it.
46		do
47			from_external_pointer(g_string_chunk_new(a_size))
48		end
49
50	-- g_string_chunk_insert ()
51
52	-- gchar*      g_string_chunk_insert           (GStringChunk *chunk,
53	--                                              const gchar *string);
54
55	-- Adds a copy of string to the G_STRING_CHUNK. It returns a pointer to the new copy of the string in the G_STRING_CHUNK. The characters in the string can be changed, if necessary, though you should not change anything after the end of the string.
56
57	-- 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.
58	-- chunk : 	a GStringChunk.
59	-- string : 	the string to add.
60	-- Returns : 	a pointer to the copy of string within the GStringChunk.
61	-- g_string_chunk_insert_const ()
62
63	-- gchar*      g_string_chunk_insert_const     (GStringChunk *chunk,
64	--                                              const gchar *string);
65
66	-- Adds a copy of string to the G_STRING_CHUNK, unless the same string has already been added to the G_STRING_CHUNK with g_string_chunk_insert_const().
67
68	-- 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.
69
70	-- 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.
71	-- chunk : 	a GStringChunk.
72	-- string : 	the string to add.
73	-- Returns : 	a pointer to the new or existing copy of string within the GStringChunk.
74	-- g_string_chunk_insert_len ()
75
76	-- gchar*      g_string_chunk_insert_len       (GStringChunk *chunk,
77	--                                              const gchar *string,
78	--                                              gssize len);
79
80	-- Adds a copy of the first len bytes of string to the GStringChunk. The copy is nul-terminated.
81
82	-- The characters in the string can be changed, if necessary, though you should not change anything after the end of the string.
83
84	-- chunk : 	a GStringChunk
85	-- string : 	bytes to insert
86	-- len : 	number of bytes of string to insert, or -1 to insert a nul-terminated string.
87	-- Returns : 	a pointer to the copy of string within the GStringChunk
88
89	-- Since 2.4
90	-- g_string_chunk_free ()
91
92	-- void        g_string_chunk_free             (GStringChunk *chunk);
93
94	-- 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.
95	-- chunk : 	a GStringChunk.
96end