dmi_buffer_read

Synopsis

#include <opendmi/buffer.h>

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

Description

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

This is what dmi_reader_t reads through; the reader keeps a cursor and a range of its own, and is what the decoding of the data is written against.

Parameters

buffer

Buffer to read from.

ptr

Buffer that receives the data; must be at least length bytes.

offset

Byte offset from the beginning of the data.

length

Number of the bytes to read.

Return value

true on success, false if the buffer holds fewer bytes than the requested range.

Errors

DMI_ERROR_ARGUMENT_NULL

Data is nullptr, while the length is not zero.