summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib/reallocarr.3
diff options
context:
space:
mode:
authorwiz <wiz@NetBSD.org>2015-02-19 23:08:21 +0000
committerwiz <wiz@NetBSD.org>2015-02-19 23:08:21 +0000
commitfbab25ea7df65d7e3aefba0d1d1461eacc4abbbe (patch)
treedfb3a85b0051bb99da62d611ffb4ed544fa9904d /lib/libc/stdlib/reallocarr.3
parent5c9d716fdca10ab6b72fbdb51524db9b0a985b3a (diff)
Add EXAMPLES section, from Youri Mouton.
Bump date.
Diffstat (limited to 'lib/libc/stdlib/reallocarr.3')
-rw-r--r--lib/libc/stdlib/reallocarr.321
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/libc/stdlib/reallocarr.3 b/lib/libc/stdlib/reallocarr.3
index e4972834358..c45d56feb4c 100644
--- a/lib/libc/stdlib/reallocarr.3
+++ b/lib/libc/stdlib/reallocarr.3
@@ -1,4 +1,4 @@
-.\" $NetBSD: reallocarr.3,v 1.2 2015/02/18 08:46:43 wiz Exp $
+.\" $NetBSD: reallocarr.3,v 1.3 2015/02/19 23:08:21 wiz Exp $
.\"
.\" Copyright (c) 2015 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -26,7 +26,7 @@
.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
-.Dd February 5, 2015
+.Dd February 19, 2015
.Dt REALLOCARR 3
.Os
.Sh NAME
@@ -55,6 +55,23 @@ Otherwise, an error code (see
is returned and
.Fa *ptr
and the referenced memory is unmodified.
+.Sh EXAMPLES
+The following uses
+.Fn reallocarr
+to initialize an array of INITSIZE integers, then
+resizes it to NEWSIZE elements:
+.Bd -literal -offset indent
+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");
+.Ed
.Sh SEE ALSO
.Xr calloc 3
.Sh HISTORY