GNOME Bugzilla – Bug 605733
g_memory_output_stream_new violates GObject standards
Last modified: 2010-01-06 22:48:06 UTC
GMemoryOutputStream does not use construct-only properties in its constructor, and instead directly initializes its private fields. Because of this, it is not easily bindable, for example Gio::MemoryOutputStream does not work at all - see #605710.
Created attachment 150587 [details] [review] Implement properties for GMemoryOutputStream This implements the missing properties on GMemoryOutputStream. O chose the following names: "data", "size", "data-size", "realloc-function", "destroy-function". "data-size" is the size of valid data. I added a test in gio/test/memory-output-stream.c that verifies that GMemoryOutputStream can be created using g_object_new, and that its properties correspond to the return values of helper methods. Also fixed are two minor problems I noticed while writing this: 1. On 32-bit systems, when the buffer size is >= 2GiB and user writes slightly more data than fits in it, the size wraps over and the stream is silently truncated to 16 bytes. 2. The buffer cannot grow beyond 2GiB on 64-bit systems, because code reported size > G_MAXUINT as an error. (It tries to allocate exactly 0x100000000 bytes = 4GiB after 2GiB are exhausted.)
Review of attachment 150587 [details] [review]: ::: gio/gmemoryoutputstream.c @@ +154,3 @@ + P_("Pointer to buffer where data will be written."), + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); Please use G_PARAM_STATIC_STRINGS here and below. @@ +212,3 @@ + break; + case PROP_DATA_SIZE: + // this should never be set, even in the constructor No single-line comments, please. Just nuke the whole case, since this is a read-only property. @@ +327,3 @@ + gsize size, + GReallocFunc realloc_function, + GDestroyNotify destroy_function) You need to fix up the doc comment to match the changed parameter names, here.
Created attachment 150711 [details] [review] Implement properties for GMemoryOutputStream v2 Amended patch with the mentioned issues fixed.
Looks good now. Please commit
I don't have commit access.
No worries, I've committed it.