GNOME Bugzilla – Bug 54903
Add non-initialized space to a GString
Last modified: 2011-02-18 15:47:43 UTC
This patch allows g_string_[append,prepend,insert]_len to take a NULL argument for the string and insert uninitialized space into the string. This is useful, e.g. in the new GIOChannel implementation (see bug 52811), where GString is used as a buffer and read_raw (an internal function) needs a character buffer to read data into. This patch also modifies the behavior of g_string_new_len to match the behavior of the other functions. Previously, if passed a NULL, g_string_new_len mimicked the behavior of g_string_sized_new, making the (non user visible) internal buffer of size len, but still making the apparent length of the string zero. Now, it makes the apparent length of the string equal to len, but does not initialize the space. This change does not appear to affect the performance of the code in the two locations that g_string_new_len is called internally in glib, in gmarkup.c and in gobject/gboxed.c.
Created attachment 544 [details] [review] patch described above
The code in this patch has been incorporated into bug 52811 (the big GIOChannel patch). *** This bug has been marked as a duplicate of 52811 ***