summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2003-09-25 11:10:57 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2003-09-25 11:10:57 +0000
commit461f4d0964c932fce73c1b5d82b4e441de0fed77 (patch)
tree0ecadf0a8b58bbbfcd47d91dd9f9354dbd531560 /lib
parentd85bab6fdcac293a0099610eee241d0654939a61 (diff)
improve example even more
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/stdlib/malloc.37
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/libc/stdlib/malloc.3 b/lib/libc/stdlib/malloc.3
index d92ebdb2b4f..73124a2040f 100644
--- a/lib/libc/stdlib/malloc.3
+++ b/lib/libc/stdlib/malloc.3
@@ -30,7 +30,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $OpenBSD: malloc.3,v 1.29 2003/09/18 22:49:13 tedu Exp $
+.\" $OpenBSD: malloc.3,v 1.30 2003/09/25 11:10:56 deraadt Exp $
.\"
.Dd August 27, 1996
.Dt MALLOC 3
@@ -158,13 +158,14 @@ indicates that the old object still remains allocated.
Better code looks like this:
.Bd -literal -offset indent
newsize = size + 50;
-if ((p2 = realloc(p, newsize)) == NULL) {
+if ((newp = realloc(p, newsize)) == NULL) {
if (p)
free(p);
p = NULL;
+ size = 0;
return (NULL);
}
-p = p2;
+p = newp;
size = newsize;
.Ed
.Pp