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)For a valid handle, *required always receives the buffer length, so a call with NULL output and zero capacity queries the size.
Parameters
| Name | Description |
|---|---|
handle | Live buffer handle. |
output | Destination. May be NULL when the buffer is empty or when capacity is 0 for a size query. |
capacity | Size of output in bytes. |
required | Receives 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.