dmi_encoder_put_bytes_at

Synopsis

#include <opendmi/encoder.h>

bool dmi_encoder_put_bytes_at(
        dmi_encoder_t *encoder,
        const void    *ptr,
        size_t         offset,
        size_t         length);

Description

The dmi_encoder_put_bytes_at function writes length bytes at ptr at offset from the beginning of the structure, without moving the position.

The function is meant for the bytes written already, which is how a value the rest of the structure decides, such as a length, is filled in once it is known. The bytes past the position are not refused, but are written over by whatever is written next, since the position does not follow them.

Parameters

encoder

Encoder to write to.

ptr

Bytes to write.

offset

Byte offset from the beginning of the structure.

length

Number of the bytes.

Return value

true on success, false otherwise.

Errors

DMI_ERROR_ARGUMENT_NULL

ptr is nullptr, while length is not zero.

DMI_ERROR_OUT_OF_MEMORY

Buffer of the writer cannot grow.