dmi_buffer_assign

Synopsis

#include <opendmi/buffer.h>

bool dmi_buffer_assign(dmi_buffer_t *buffer, const void *ptr, size_t length);

Description

The dmi_buffer_assign function replaces whatever the buffer holds with a copy of length bytes at ptr.

Buffers own their memory, so the data is copied rather than referred to, and the caller keeps whatever it has passed.

Parameters

buffer

Buffer to fill.

ptr

Data to copy, which may be nullptr when length is zero.

length

Number of the bytes to copy.

Return value

true on success, false otherwise.

Errors

DMI_ERROR_ARGUMENT_NULL

Data is nullptr, while the length is not zero.

DMI_ERROR_OUT_OF_MEMORY

Memory of the buffer cannot grow.