Synopsis#include <gio/gio.h> gpointer (*GReallocFunc) (gpointer data, gsize size); GMemoryOutputStream; GOutputStream* g_memory_output_stream_new (gpointer data, gsize len, GReallocFunc realloc_fn, GDestroyNotify destroy); 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); DescriptionGMemoryOutputStream is a class for using arbitrary memory chunks as output for GIO streaming output operations.
DetailsGReallocFunc ()gpointer (*GReallocFunc) (gpointer data, gsize size);
Changes the size of the memory block pointed to by
The function should have the same semantics as
GMemoryOutputStreamtypedef struct _GMemoryOutputStream GMemoryOutputStream; Implements GOutputStream for arbitrary memory chunks.
g_memory_output_stream_new ()GOutputStream* g_memory_output_stream_new (gpointer data, gsize len, GReallocFunc realloc_fn, GDestroyNotify destroy); Creates a new GMemoryOutputStream.
If /* a stream that can grow */ stream = g_memory_output_stream_new (NULL, 0, realloc, free); /* a fixed-size stream */ data = malloc (200); stream2 = g_memory_output_stream_new (data, 200, NULL, free);
g_memory_output_stream_get_data ()gpointer g_memory_output_stream_get_data (GMemoryOutputStream *ostream);
Gets any loaded data from the Note that the returned pointer may become invalid on the next write or truncate operation on the stream.
g_memory_output_stream_get_size ()gsize g_memory_output_stream_get_size (GMemoryOutputStream *ostream);
Gets the size of the currently allocated data area (availible from
Note that for growable streams the returned size may become invalid on the next write or truncate operation on the stream.
If you want the number of bytes currently written to the stream, use
g_memory_output_stream_get_data_size ()gsize g_memory_output_stream_get_data_size (GMemoryOutputStream *ostream); Returns the number of bytes from the start up to including the last byte written in the stream that has not been truncated away.
Since 2.18 |