Browse Source

It is safe to pass free() a NULL pointer since C89; update example to

this effect.  OK deraadt@ pvalchev@
OPENBSD_3_5
millert 21 years ago
parent
commit
2a6996bfa4
1 changed files with 2 additions and 3 deletions
  1. +2
    -3
      src/lib/libc/stdlib/malloc.3

+ 2
- 3
src/lib/libc/stdlib/malloc.3 View File

@ -30,7 +30,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: malloc.3,v 1.30 2003/09/25 11:10:56 deraadt Exp $
.\" $OpenBSD: malloc.3,v 1.31 2003/09/26 05:57:02 millert Exp $
.\" .\"
.Dd August 27, 1996 .Dd August 27, 1996
.Dt MALLOC 3 .Dt MALLOC 3
@ -159,8 +159,7 @@ Better code looks like this:
.Bd -literal -offset indent .Bd -literal -offset indent
newsize = size + 50; newsize = size + 50;
if ((newp = realloc(p, newsize)) == NULL) { if ((newp = realloc(p, newsize)) == NULL) {
if (p)
free(p);
free(p);
p = NULL; p = NULL;
size = 0; size = 0;
return (NULL); return (NULL);


Loading…
Cancel
Save