Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/stdlib Restore the behaviour of not setting errno t...
details: https://anonhg.NetBSD.org/src/rev/60db36d650f6
branches: trunk
changeset: 476240:60db36d650f6
user: kleink <kleink%NetBSD.org@localhost>
date: Fri Sep 10 10:38:06 1999 +0000
description:
Restore the behaviour of not setting errno to ENOMEM when allocating 0
units of storage and returning a null pointer in System V mode; this was
broken by the `fix' in rev. 1.24. Also, as it is stated in ISO C that
such operation does not constitute an allocation failure, do not abort()
even if the `X' option is set.
Amusingly enough the SVID, Fourth Edition, specifies the `unique pointer'
return behaviour for this kind of allocation, so this is kind of mis-named.
diffstat:
lib/libc/stdlib/malloc.3 | 5 +----
lib/libc/stdlib/malloc.c | 6 +++---
2 files changed, 4 insertions(+), 7 deletions(-)
diffs (46 lines):
diff -r 7a8a02569af7 -r 60db36d650f6 lib/libc/stdlib/malloc.3
--- a/lib/libc/stdlib/malloc.3 Fri Sep 10 10:12:09 1999 +0000
+++ b/lib/libc/stdlib/malloc.3 Fri Sep 10 10:38:06 1999 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: malloc.3,v 1.10 1999/08/02 03:18:47 lukem Exp $
+.\" $NetBSD: malloc.3,v 1.11 1999/09/10 10:38:06 kleink Exp $
.\"
.\" Copyright (c) 1980, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -207,9 +207,6 @@
(The default behavior is to make a minimal allocation and return a
pointer to it.)
This option is provided for System V compatibility.
-This option is incompatible with the
-.Dq X
-option.
.It X
Rather than return failure for any allocation function,
display a diagnostic message on stderr and cause the program to drop
diff -r 7a8a02569af7 -r 60db36d650f6 lib/libc/stdlib/malloc.c
--- a/lib/libc/stdlib/malloc.c Fri Sep 10 10:12:09 1999 +0000
+++ b/lib/libc/stdlib/malloc.c Fri Sep 10 10:38:06 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: malloc.c,v 1.25 1999/08/22 12:54:03 kleink Exp $ */
+/* $NetBSD: malloc.c,v 1.26 1999/09/10 10:38:06 kleink Exp $ */
/*
* ----------------------------------------------------------------------------
@@ -1083,7 +1083,7 @@
UTRACE(0, size, r);
malloc_active--;
THREAD_UNLOCK();
- if (r == NULL) {
+ if (r == NULL && (size != 0 || !malloc_sysv)) {
if (malloc_xmalloc)
wrterror("out of memory.\n");
errno = ENOMEM;
@@ -1138,7 +1138,7 @@
UTRACE(ptr, size, r);
malloc_active--;
THREAD_UNLOCK();
- if (r == NULL) {
+ if (r == NULL && (size != 0 || !malloc_sysv)) {
if (malloc_xmalloc)
wrterror("out of memory.\n");
errno = ENOMEM;
Home |
Main Index |
Thread Index |
Old Index