demi_sgaalloc - Allocates a scatter-gather array.
#include <demi/sga.h>
#include <demi/types.h> /* For demi_sgarray_t. */
demi_sgarray_t demi_sgaalloc(size_t size);demi_sgaalloc() allocates a scatter gather-array of size bytes and returns it.
Depending on the underlying libOS, memory is allocated from a zero-copy memory pool.
The demi_sgarray_t structure is defined as follows:
typedef struct demi_sgarray
{
// Reserved.
void *sga_buf;
// Number of segments in the scatter-gather array.
uint32_t sga_numsegs;
// Scatter-gather array segments.
demi_sgaseg_t segments[DEMI_SGARRAY_MAXSIZE];
// Source address of scatter-gather array.
struct sockaddr_in sga_addr;
} demi_sgarray_t;The demi_sgaseg_t is defined as follows:
typedef struct demi_sgaseg
{
// Underlying data.
void *data_buf_ptr;
// Size in bytes of data.
uint32_t data_len_bytes;
} demi_sgaseg_t;On success, the allocated scatter-gather array is returned. On error, a null scatter-gather array is returned.
A null scatter-gather array is one that has zero segments, that is the sga_numsegs member field set to zero.
Any behavior that is not documented in this manual page is unintentional and should be reported.
demi_sgafree().