Skip to content
Start free evaluation

pdcomm_buffer_copy

Function

Copies the bytes of a buffer into caller storage.

PdcommStatus pdcomm_buffer_copy(const PdcommBuffer *handle, uint8_t *output, size_t capacity, size_t *required)

Declared in: #include <pdcomm.h>

For a valid handle, *required always receives the buffer length, so a call with NULL output and zero capacity queries the size.

Parameters

NameDescription
handleLive buffer handle.
outputDestination. May be NULL when the buffer is empty or when capacity is 0 for a size query.
capacitySize of output in bytes.
requiredReceives the buffer length (0 when handle is NULL). Must not be NULL and must not overlap output or the handle.

Returns

#PDCOMM_OK when all bytes were copied; #PDCOMM_BUFFER_TOO_SMALL when capacity is smaller than the length (output untouched); #PDCOMM_INVALID_ARGUMENT when required or handle is NULL, or output is NULL for nonempty data with sufficient capacity; #PDCOMM_INTERNAL_ERROR when a panic was contained.

Notes

  • Thread safety: copy calls on the same handle may run concurrently. Destruction must not run concurrently with any other call on the handle.