BUF_SHRINK(3) - Library Functions Manual

NAME

buf_shrink - reduce the buffer to its minimal requirement

SYNOPSIS

#include <buf.h>

bool
buf_shrink(struct buf *b);

DESCRIPTION

Reduce the buffer capacity specified by b to reduce memory usage.

The buf_shrink() function will reduce the buffer capacity to the exact buffer length. If reallocation of the new memory region failed, the current buffer is kept and its capacity is unchanged. As such, it is perfectly safe to ignore the return value unless you really want to reduce memory consumption

RETURN VALUE

If the buffer’s length is 0, the function simply frees the underlying data and return true.

Otherwise the buf_shrink() function returns false in case of error and errno is set to indicate the error.

ERRORS

[ENOMEM]

Memory reallocation failed.

SEE ALSO

libbuf(3)

AUTHORS

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

macOS 11.2 - October 29, 2019-2020