Module Name:    src
Committed By:   wiz
Date:           Thu Feb 19 23:08:21 UTC 2015

Modified Files:
        src/lib/libc/stdlib: reallocarr.3

Log Message:
Add EXAMPLES section, from Youri Mouton.
Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/stdlib/reallocarr.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/stdlib/reallocarr.3
diff -u src/lib/libc/stdlib/reallocarr.3:1.2 src/lib/libc/stdlib/reallocarr.3:1.3
--- src/lib/libc/stdlib/reallocarr.3:1.2	Wed Feb 18 08:46:43 2015
+++ src/lib/libc/stdlib/reallocarr.3	Thu Feb 19 23:08:21 2015
@@ -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

Reply via email to