GMimeStreamBlock

GMimeStreamBlock — Non-contiguous memory streams

Functions

Types and Values

Description

Ports MimeKit's MemoryBlockStream using 2048-byte blocks. Growing the stream does not copy previously stored bytes. Seeking cannot extend the stream; use g_mime_stream_block_set_length() to grow it before seeking. New blocks are zero-initialized rather than rented from a managed pool.

Native bounds and substreams use absolute coordinates, including SEEK_SET. Substreams share storage and length but have independent positions and bounds. Closing one view does not close another. Reset rewinds without discarding content. Nonempty I/O, position, length, reset and flush fail with EBADF after close; native zero-length I/O remains a no-op.

The backing length is limited to G_MAXINT * 2048 bytes. As in MimeKit, writes ending at that limit are rejected, although setting length accepts it. Allocation follows GLib's normal allocation policy. The optional contiguous copy is limited to G_MAXUINT bytes.

Functions

g_mime_stream_block_new ()

GMimeStream *
g_mime_stream_block_new (void);

Creates an empty memory stream backed by 2048-byte blocks.

Returns

a new GMimeStreamBlock.

[transfer full]


g_mime_stream_block_set_length ()

int
g_mime_stream_block_set_length (GMimeStreamBlock *stream,
                                gint64 length);

Resizes the shared backing store to the start bound plus length . Growing exposes zero-initialized bytes. Shrinking releases unneeded blocks and clears the truncated tail before it can be exposed again. The caller's position is clamped to the new end; other views retain their positions. A finite end bound is updated to the new end.

Parameters

stream

a GMimeStreamBlock

 

length

new length, relative to the stream's start bound

 

Returns

0 on success or -1 on error, setting errno to EBADF for a closed stream, EINVAL for negative length or EOVERFLOW for an excessive extent.


g_mime_stream_block_to_byte_array ()

GByteArray *
g_mime_stream_block_to_byte_array (GMimeStreamBlock *stream,
                                   GError **error);

Copies the bytes within the stream's bounds into an independent contiguous array without changing position. The caller owns the returned copy.

Parameters

stream

a GMimeStreamBlock

 

error

return location for a GError, or NULL

 

Returns

the copied bytes, or NULL on error, setting errno and error . Errors use GMIME_ERROR with errno codes, including EBADF after close and EOVERFLOW above G_MAXUINT bytes.

[transfer full][nullable]

Types and Values

GMimeStreamBlock

typedef struct _GMimeStreamBlock GMimeStreamBlock;

A memory stream backed by non-contiguous 2048-byte blocks.

See Also

GMimeStreamMem