GNOME Bugzilla – Bug 96279
Add g_string_chunk_insert_len() function.
Last modified: 2011-02-18 16:07:08 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
Created attachment 11695 [details] [review] Update patch to current cvs.
2.2 API freeze already has more on it than we can handle for GLib
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.
Created attachment 15319 [details] [review] Updated patch
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
Committed to HEAD.