istream_new_gbuffer()

istream_new_gbuffer()#

Creates a new gbuffer_t * for the specified istream. The old gbuffer_t * associated with the istream is released. The new buffer is initialized with the specified data and maximum sizes.

Prototype

PUBLIC int istream_new_gbuffer(
    istream_h   istream,
    size_t      data_size,
    size_t      max_size
);

Parameters

Key

Type

Description

istream

istream_h

The handle to the istream where the new gbuffer_t * will be created.

data_size

size_t

The size of the initial data allocation for the new gbuffer_t *.

max_size

size_t

The maximum size the new gbuffer_t * can grow to.


Return Value

Returns 0 on success. Returns -1 if the istream is NULL, or if memory allocation fails.

Notes

  • The previous gbuffer_t * is decremented and freed using GBUFFER_DECREF before assigning the new buffer.

  • This function logs an error if the istream is NULL or if the new buffer creation fails.

  • Ensure that the istream is valid before calling this function to avoid memory errors.

Prototype

// Not applicable in JS

Prototype

# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples