BUF_RESIZE(3) - Library Functions Manual

NAME

buf_resize - change string length

SYNOPSIS

#include <buf.h>

bool
buf_resize(struct buf *b, size_t size, char c);

DESCRIPTION

Change the buffer length specified by b to the new size and optionally fill new space with character c.

This function serves two purposes, it can reduce the string length if the size argument is smaller than current b length or it can increase it and fill the new region with c. In the first case, the function never fails in the second it may need to reallocate data which could fail if no memory is available.

Note that in constrast to buf_shrink() function, the buf_resize() function never reallocate data if the new size is smaller, you may want to call buf_shrink() if memory should be released.

RETURN VALUE

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

ERRORS

[ENOMEM]

Couldn’t allocate more memory.

SEE ALSO

libbuf(3), buf_resize(3), buf_shrink(3)

AUTHORS

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

Mac OS X 10.15 - October 29, 2019-2020