diff options
| author | wiz <wiz@NetBSD.org> | 2015-02-06 08:37:39 +0000 |
|---|---|---|
| committer | wiz <wiz@NetBSD.org> | 2015-02-06 08:37:39 +0000 |
| commit | 7bf38fa40e1eb90620f458cd953530b551ec557e (patch) | |
| tree | b7a3c5be23ac8b3df73d08b335e88ed8ba4b1352 /lib/libc/stdlib/malloc.3 | |
| parent | fe26ea7a7a097749b8db45e67f5f5bad304c06d5 (diff) | |
Remove trailing whitespace.
Diffstat (limited to 'lib/libc/stdlib/malloc.3')
| -rw-r--r-- | lib/libc/stdlib/malloc.3 | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/lib/libc/stdlib/malloc.3 b/lib/libc/stdlib/malloc.3 index 50e7f778598..21cc1515c94 100644 --- a/lib/libc/stdlib/malloc.3 +++ b/lib/libc/stdlib/malloc.3 @@ -1,4 +1,4 @@ -.\" $NetBSD: malloc.3,v 1.40 2015/02/05 20:02:28 christos Exp $ +.\" $NetBSD: malloc.3,v 1.41 2015/02/06 08:37:39 wiz Exp $ .\" .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -175,18 +175,18 @@ if (size && number > SIZE_MAX / size) { The above test is not sufficient in all cases. For example, multiplying ints requires a different set of checks: .Bd -literal -offset indent -int num, size; -\&.\&.\&. - -/* Avoid invalid requests */ -if (size < 0 || num < 0) - errc(1, EOVERFLOW, "overflow"); - -/* Check for signed int overflow */ -if (size && num > INT_MAX / size) - errc(1, EOVERFLOW, "overflow"); - -if ((p = malloc(size * num)) == NULL) +int num, size; +\&.\&.\&. + +/* Avoid invalid requests */ +if (size < 0 || num < 0) + errc(1, EOVERFLOW, "overflow"); + +/* Check for signed int overflow */ +if (size && num > INT_MAX / size) + errc(1, EOVERFLOW, "overflow"); + +if ((p = malloc(size * num)) == NULL) err(1, "malloc"); .Ed .Pp @@ -194,18 +194,18 @@ Assuming the implementation checks for integer overflow as .Nx does, it is much easier to use .Fn calloc -or +or .Xr reallocarr 3 . .Pp The above examples could be simplified to: .Bd -literal -offset indent ptr = NULL; -if ((e = reallocarr(&ptr, num, size))) +if ((e = reallocarr(&ptr, num, size))) errx(1, "reallocarr", strerror(e)); .Ed .Bd -literal -offset indent or at the cost of initialization: -if ((p = calloc(num, size)) == NULL) +if ((p = calloc(num, size)) == NULL) err(1, "calloc"); .Ed .Pp |
