Add g_memory_output_stream_steal_data

Bug #622184.
This commit is contained in:
Christian Persch 2010-06-20 14:32:52 +02:00
parent 322ac7ff68
commit b196cd7447
4 changed files with 32 additions and 0 deletions

View 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

View 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

View 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,

View 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