Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/stdlib Add EXAMPLES section, from Youri Mouton.
details: https://anonhg.NetBSD.org/src/rev/ae9d991fb427
branches: trunk
changeset: 336229:ae9d991fb427
user: wiz <wiz%NetBSD.org@localhost>
date: Thu Feb 19 23:08:21 2015 +0000
description:
Add EXAMPLES section, from Youri Mouton.
Bump date.
diffstat:
lib/libc/stdlib/reallocarr.3 | 21 +++++++++++++++++++--
1 files changed, 19 insertions(+), 2 deletions(-)
diffs (42 lines):
diff -r fb8fead102cb -r ae9d991fb427 lib/libc/stdlib/reallocarr.3
--- a/lib/libc/stdlib/reallocarr.3 Thu Feb 19 21:44:50 2015 +0000
+++ b/lib/libc/stdlib/reallocarr.3 Thu Feb 19 23:08:21 2015 +0000
@@ -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 @@
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
Home |
Main Index |
Thread Index |
Old Index