reallocarr(3) - NetBSD Manual Pages

Command: Section: Arch: Collection:  
REALLOCARR(3)           NetBSD Library Functions Manual          REALLOCARR(3)


NAME
reallocarr -- reallocate array
SYNOPSIS
#include <stdlib.h> int reallocarr(void *ptr, size_t number, size_t size);
DESCRIPTION
The reallocarr function reallocates the memory in *ptr.
RETURN VALUES
On successful completion, returns 0 and updates *ptr. Otherwise, an error code (see errno(2)) is returned and *ptr and the referenced memory is unmodified.
EXAMPLES
The following uses reallocarr() to initialize an array of INITSIZE inte- gers, then resizes it to NEWSIZE elements: int *data = NULL; int ret = 0; ret = reallocarr(&data, INITSIZE, sizeof(*data)); if (ret) errc(1, ret, "reallocarr failed"); ret = reallocarr(&data, NEWSIZE, sizeof(*data)); if (ret) errc(1, ret, "reallocarr failed on resize");
SEE ALSO
calloc(3)
HISTORY
reallocarr first appeared in NetBSD 7.0. OpenBSD introduced the reallocarray(3) function for the same purpose, but the interface makes it difficult to correctly handle zero-sized allocations. NetBSD 9.1 February 19, 2015 NetBSD 9.1
Powered by man-cgi (2021-03-02). Maintained for NetBSD by Kimmo Suominen. Based on man-cgi by Panagiotis Christias.