mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-30 04:44:16 +02:00
GMemoryOutputStream: Add new _resizable() constructor usable from bindings
Really, the memory output stream API is too warped around the model where it's a fixed size buffer that you've already allocated. Even in C, I find myself always wanting to use it to just accumulate data into an arbitrary-sized buffer it allocates. Unfortunately, it's also not usable from bindings because it's not common to bind g_free() and g_realloc(), but if you just pass NULL, you get the default of a fixed size, which is useless as per above. I am going to use this from a gjs test case, and the GSubprocess test cases also will use it. https://bugzilla.gnome.org/show_bug.cgi?id=688931
This commit is contained in:
@@ -34,7 +34,7 @@ test_truncate (void)
|
||||
|
||||
g_test_bug ("540423");
|
||||
|
||||
mo = g_memory_output_stream_new (NULL, 0, g_realloc, g_free);
|
||||
mo = g_memory_output_stream_new_resizable ();
|
||||
g_assert (g_seekable_can_truncate (G_SEEKABLE (mo)));
|
||||
o = g_data_output_stream_new (mo);
|
||||
for (i = 0; i < 1000; i++)
|
||||
@@ -86,7 +86,7 @@ test_data_size (void)
|
||||
|
||||
g_test_bug ("540459");
|
||||
|
||||
mo = g_memory_output_stream_new (NULL, 0, g_realloc, g_free);
|
||||
mo = g_memory_output_stream_new_resizable ();
|
||||
o = g_data_output_stream_new (mo);
|
||||
g_data_output_stream_put_byte (o, 1, NULL, NULL);
|
||||
pos = g_memory_output_stream_get_data_size (G_MEMORY_OUTPUT_STREAM (mo));
|
||||
|
Reference in New Issue
Block a user