dmi_buffer_resize

Synopsis

#include <opendmi/buffer.h>

bool dmi_buffer_resize(dmi_buffer_t *buffer, size_t length);

Description

The dmi_buffer_resize function sets the number of the bytes the buffer holds. The bytes a longer buffer gains are set to zero, and the ones a shorter buffer loses are dropped without the memory being given back, so that the buffer emptied with a length of zero writes the data next without allocating again.

Parameters

buffer

Buffer to resize.

length

Number of the bytes the buffer is to hold.

Return value

true on success, false otherwise.

Errors

DMI_ERROR_OUT_OF_MEMORY

Memory of the buffer cannot grow.