BUF_RESIZE(3) - Library Functions Manual
buf_resize - change string length
#include <buf.h>
int
buf_resize(struct buf *b, size_t
size, char c);
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.
The buf_resize() function returns -1 in case of error and errno is set to indicate the error.
[ENOMEM
]
Couldn’t allocate more memory.
libbuf(3), buf_resize(3), buf_shrink(3)
The libbuf library was written by David Demelier <markand@malikania.fr>
macOS 12.5 - October 29, 2019-2022