[glib] Add g_memory_output_stream_steal_data
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Add g_memory_output_stream_steal_data
- Date: Tue, 17 Aug 2010 15:39:56 +0000 (UTC)
commit b196cd74473cbc812359ee3b484a3986604e9aba
Author: Christian Persch <chpe gnome org>
Date: Sun Jun 20 14:32:52 2010 +0200
Add g_memory_output_stream_steal_data
Bug #622184.
docs/reference/gio/gio-sections.txt | 1 +
gio/gio.symbols | 1 +
gio/gmemoryoutputstream.c | 29 +++++++++++++++++++++++++++++
gio/gmemoryoutputstream.h | 1 +
4 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt
index cd23dea..c6aa574 100644
--- a/docs/reference/gio/gio-sections.txt
+++ b/docs/reference/gio/gio-sections.txt
@@ -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
diff --git a/gio/gio.symbols b/gio/gio.symbols
index eb23edd..5f439cf 100644
--- a/gio/gio.symbols
+++ b/gio/gio.symbols
@@ -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
diff --git a/gio/gmemoryoutputstream.c b/gio/gmemoryoutputstream.c
index eada0a7..3b7ec2c 100644
--- a/gio/gmemoryoutputstream.c
+++ b/gio/gmemoryoutputstream.c
@@ -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,
diff --git a/gio/gmemoryoutputstream.h b/gio/gmemoryoutputstream.h
index ddb4051..bcdc164 100644
--- a/gio/gmemoryoutputstream.h
+++ b/gio/gmemoryoutputstream.h
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]