Browse Source

Modify example not to use an assignment in the if statement. We shouldn't

teach people bad habits!
ok krw@, jmc@, dlg@, thib@
OPENBSD_4_8
kettenis 14 years ago
parent
commit
92dc8ab6e1
1 changed files with 4 additions and 3 deletions
  1. +4
    -3
      src/lib/libc/string/strdup.3

+ 4
- 3
src/lib/libc/string/strdup.3 View File

@ -1,4 +1,4 @@
.\" $OpenBSD: strdup.3,v 1.14 2007/05/31 19:19:32 jmc Exp $
.\" $OpenBSD: strdup.3,v 1.15 2010/03/24 14:47:46 kettenis Exp $
.\"
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@ -29,7 +29,7 @@
.\"
.\" @(#)strdup.3 8.1 (Berkeley) 6/9/93
.\"
.Dd $Mdocdate: May 31 2007 $
.Dd $Mdocdate: March 24 2010 $
.Dt STRDUP 3
.Os
.Sh NAME
@ -59,7 +59,8 @@ to an allocated area of memory containing the NUL-terminated string
.Bd -literal -offset indent
char *p;
if ((p = strdup("foobar")) == NULL) {
p = strdup("foobar");
if (p == NULL) {
fprintf(stderr, "Out of memory.\en");
exit(1);
}


Loading…
Cancel
Save