BUF_SUB(3) - Library Functions Manual

NAME

buf_sub - duplicate a specific portion from the buffer

SYNOPSIS

#include <buf.h>

int
buf_sub(struct buf *b, const struct buf *src, size_t pos, size_t count);

DESCRIPTION

Extract the portion at position pos from the buffer specified by src with count number of characters and set to b.

This function will first initialize and allocate the buffer specified by b to fill the portion length. It should not contain any data because it will be overwritten.

The count argument can be set to -1 to extract data until the end of the src buffer.

Undefined behavior may occur if the pos argument is outside of the buffer bounds.

RETURN VALUE

The buf_sub() function returns -1 in case of error and errno is set to indicate the error.

ERRORS

[ENOMEM]

Memory allocation failed.

SEE ALSO

libbuf(3)

AUTHORS

The libbuf library was written by David Demelier <markand@malikania.fr>

macOS 13.5 - October 29, 2019-2022