dmi_buffer_write

Synopsis

#include <opendmi/buffer.h>

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

Description

The dmi_buffer_write function copies length bytes at ptr into the data of the buffer, at offset from its beginning.

The data grows if the bytes are written past its end, and the ones between the end and offset are set to zero, the way the bytes a longer buffer gains are.

This is what dmi_writer_t writes through; the writer keeps a cursor and a range of its own, and is what the encoding of the data is written against.

Parameters

buffer

Buffer to write to.

ptr

Data to write.

offset

Byte offset from the beginning of the data.

length

Number of the bytes to write.

Return value

true on success, false otherwise.

Errors

DMI_ERROR_ARGUMENT_NULL

Data is nullptr, while the length is not zero.

DMI_ERROR_ARGUMENT_INVALID

Data ends past what a size holds, i.e. the sum of the offset and the length overflows.

DMI_ERROR_OUT_OF_MEMORY

Memory of the buffer cannot grow.