dmi_buffer_at

Synopsis

#include <opendmi/buffer.h>

const dmi_data_t *dmi_buffer_at(
        const dmi_buffer_t *buffer,
        size_t              offset,
        size_t              length);

Description

The dmi_buffer_at function refers to length bytes at offset from the beginning of the data of the buffer.

The data is referred to in place rather than copied, which is how the strings and the binary members of the decoded structures refer to it, and stays valid for as long as the buffer holds it: writing to the buffer may move the data, and destroying the buffer frees it.

Parameters

buffer

Buffer to refer to.

offset

Byte offset from the beginning of the data.

length

Number of the bytes to refer to, which may be zero.

Return value

Pointer to the data, or nullptr if the buffer holds fewer bytes than the requested range.

A buffer which has never held data has no memory to point into, so nullptr is returned for the range of no bytes at its beginning as well.

Errors

None.