BUF_RESERVE(3) - Library Functions Manual

NAME

buf_reserve - allocate more storage for next operations

SYNOPSIS

#include <buf.h>

int
buf_reserve(struct buf *b, size_t desired);

DESCRIPTION

The buf_reserve() function tries to increase the buffer’s capacity specified by b to the amount of desired.

Once the new capacity is increased the next calls to any operation that would append data to the buffer can avoid reallocating the memory. This can be useful if you know in advance which storage space you need.

If it was unable to acquire more memory, the buffer still contains the original data and capacity remains unchanged. In any case, the buffer length’s remains unchanged and only capacity is increased.

RETURN VALUE

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

ERRORS

[ENOMEM]

Couldn’t allocate more memory.

SEE ALSO

libbuf(3)

AUTHORS

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

macOS 13.5 - October 29, 2019-2022