#include "string.h"
#include "glibintl.h"
-#include "gioalias.h"
/**
* SECTION:gmemoryoutputstream
G_PARAM_STATIC_STRINGS));
/**
- * GMemoryOutputStream:realloc-function:
+ * GMemoryOutputStream:realloc-function: (skip)
*
* Function with realloc semantics called to enlarge the buffer.
*
G_PARAM_STATIC_STRINGS));
/**
- * GMemoryOutputStream:destroy-function:
+ * GMemoryOutputStream:destroy-function: (skip)
*
* Function called with the buffer as argument when the stream is destroyed.
*
}
/**
- * g_memory_output_stream_new:
+ * g_memory_output_stream_new: (skip)
* @data: pointer to a chunk of memory to use, or %NULL
* @size: the size of @data
* @realloc_function: a function with realloc() semantics (like g_realloc())
* Note that the returned pointer may become invalid on the next
* write or truncate operation on the stream.
*
- * Returns: pointer to the stream's data
+ * Returns: (transfer none): pointer to the stream's data
**/
gpointer
g_memory_output_stream_get_data (GMemoryOutputStream *ostream)
* g_memory_output_stream_get_size:
* @ostream: a #GMemoryOutputStream
*
- * Gets the size of the currently allocated data area (availible from
+ * Gets the size of the currently allocated data area (available from
* g_memory_output_stream_get_data()). If the stream isn't
* growable (no realloc was passed to g_memory_output_stream_new()) then
* this is the maximum size of the stream and further writes
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,
GSimpleAsyncResult *simple;
gssize nwritten;
- nwritten = g_memory_output_stream_write (stream,
- buffer,
- count,
- cancellable,
- NULL);
+ nwritten = g_output_stream_write (stream,
+ buffer,
+ count,
+ cancellable,
+ NULL);
simple = g_simple_async_result_new (G_OBJECT (stream),
callback,
return TRUE;
}
-
-#define __G_MEMORY_OUTPUT_STREAM_C__
-#include "gioaliasdef.c"