Add g_memory_output_stream_steal_data
authorChristian Persch <chpe@gnome.org>
Sun, 20 Jun 2010 12:32:52 +0000 (14:32 +0200)
committerChristian Persch <chpe@gnome.org>
Tue, 17 Aug 2010 15:33:01 +0000 (17:33 +0200)
Bug #622184.

docs/reference/gio/gio-sections.txt
gio/gio.symbols
gio/gmemoryoutputstream.c
gio/gmemoryoutputstream.h

index cd23dea..c6aa574 100644 (file)
@@ -823,6 +823,7 @@ g_memory_output_stream_new
 g_memory_output_stream_get_data
 g_memory_output_stream_get_size
 g_memory_output_stream_get_data_size
+g_memory_output_stream_steal_data
 <SUBSECTION Standard>
 GMemoryOutputStreamClass
 G_MEMORY_OUTPUT_STREAM
index eb23edd..5f439cf 100644 (file)
@@ -707,6 +707,7 @@ g_memory_output_stream_new
 g_memory_output_stream_get_data
 g_memory_output_stream_get_data_size
 g_memory_output_stream_get_size
+g_memory_output_stream_steal_data
 #endif
 #endif
 
index eada0a7..3b7ec2c 100644 (file)
@@ -440,6 +440,35 @@ g_memory_output_stream_get_data_size (GMemoryOutputStream *ostream)
   return ostream->priv->valid_len;
 }
 
+/**
+ * g_memory_output_stream_steal_data:
+ * @ostream: a #GMemoryOutputStream
+ *
+ * Gets any loaded data from the @ostream. Ownership of the data
+ * is transferred to the caller; when no longer needed it must be
+ * freed using the free function set in @ostream's
+ * #GMemoryOutputStream:destroy-function property.
+ *
+ * @ostream must be closed before calling this function.
+ *
+ * Returns: (transfer full): the stream's data
+ *
+ * Since: 2.26
+ **/
+gpointer
+g_memory_output_stream_steal_data (GMemoryOutputStream *ostream)
+{
+  gpointer data;
+
+  g_return_val_if_fail (G_IS_MEMORY_OUTPUT_STREAM (ostream), NULL);
+  g_return_val_if_fail (g_output_stream_is_closed (G_OUTPUT_STREAM (ostream)), NULL);
+
+  data = ostream->priv->data;
+  ostream->priv->data = NULL;
+
+  return data;
+}
+
 static gboolean
 array_resize (GMemoryOutputStream  *ostream,
               gsize                 size,
index ddb4051..bcdc164 100644 (file)
@@ -91,6 +91,7 @@ GOutputStream *g_memory_output_stream_new           (gpointer             data,
 gpointer       g_memory_output_stream_get_data      (GMemoryOutputStream *ostream);
 gsize          g_memory_output_stream_get_size      (GMemoryOutputStream *ostream);
 gsize          g_memory_output_stream_get_data_size (GMemoryOutputStream *ostream);
+gpointer       g_memory_output_stream_steal_data    (GMemoryOutputStream *ostream);
 
 G_END_DECLS