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 605733 - g_memory_output_stream_new violates GObject standards
g_memory_output_stream_new violates GObject standards
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
2.23.x
Other All
: Normal major
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks: 605710
 
 
Reported: 2009-12-30 12:34 UTC by Krzysztof Kosiński
Modified: 2010-01-06 22:48 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Implement properties for GMemoryOutputStream (16.08 KB, patch)
2009-12-30 15:49 UTC, Krzysztof Kosiński
needs-work Details | Review
Implement properties for GMemoryOutputStream v2 (16.40 KB, patch)
2010-01-02 23:23 UTC, Krzysztof Kosiński
accepted-commit_now Details | Review

Description Krzysztof Kosiński 2009-12-30 12:34:44 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.
Comment 1 Krzysztof Kosiński 2009-12-30 15:49:30 UTC
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.)
Comment 2 Matthias Clasen 2010-01-02 23:15:13 UTC
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.
Comment 3 Krzysztof Kosiński 2010-01-02 23:23:06 UTC
Created attachment 150711 [details] [review]
Implement properties for GMemoryOutputStream v2

Amended patch with the mentioned issues fixed.
Comment 4 Matthias Clasen 2010-01-06 18:45:06 UTC
Looks good now. Please commit
Comment 5 Krzysztof Kosiński 2010-01-06 20:03:00 UTC
I don't have commit access.
Comment 6 Matthias Clasen 2010-01-06 22:48:06 UTC
No worries, I've committed it.