/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

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