After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 96279 - Add g_string_chunk_insert_len() function.
Add g_string_chunk_insert_len() function.
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
2.0.x
Other Linux
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2002-10-20 02:32 UTC by hashao
Modified: 2011-02-18 16:07 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
Update patch to current cvs. (2.76 KB, patch)
2002-10-20 03:17 UTC, hashao
none Details | Review
Updated patch (4.06 KB, patch)
2003-03-30 22:46 UTC, Matthias Clasen
none Details | Review

Description hashao 2002-10-20 02:32:21 UTC
The function is the same as g_string_chunk_insert() except the new function
also takes the max number of bytes to insert. The inserted string is
always null-terminated. The source need not to be null-terminated.

It is useful for construction of a bunch of strings from
a big buffer, e.g. mmapped files. Otherwise, string segments
have to be explicitly created before insertions. Result in a
lot of malloc's.

http://mail.gnome.org/archives/gtk-devel-list/2001-December/msg00176.html
Comment 1 hashao 2002-10-20 03:17:08 UTC
Created attachment 11695 [details] [review]
Update patch to current cvs.
Comment 2 Owen Taylor 2002-10-20 14:36:36 UTC
2.2 API freeze already has more on it than we can handle for GLib
Comment 3 Owen Taylor 2003-03-28 19:37:31 UTC
Idea sounds reasonable, but needs various changes.
 
 - Function should be called insert_len(), not n_insert().
 
 - Function should be like other _len() functions and
   have a gssize len and take < 0 to mean "use strlen"

 - Instead of duplicating the code from g_string_chunk_insert(),
   g_string_chunk_insert() should call this function with
   -1 as the length.

 - Function needs API docs

I wonder if you are the first person to use strchunks...
they certainly are pretty rare.
Comment 4 Matthias Clasen 2003-03-30 22:46:33 UTC
Created attachment 15319 [details] [review]
Updated patch
Comment 5 Owen Taylor 2003-03-31 14:57:15 UTC
Looks fine to me with two small comments:

 - insert() should have a copy of the g_return_val_if_fail()
   from insert_len() by standard GLib/GTK+ convention.

 - We generally say nul-terminated not 0-terminated
Comment 6 Matthias Clasen 2003-03-31 22:09:42 UTC
Committed to HEAD.