diff options
| author | kleink <kleink@NetBSD.org> | 1999-09-10 10:38:06 +0000 |
|---|---|---|
| committer | kleink <kleink@NetBSD.org> | 1999-09-10 10:38:06 +0000 |
| commit | 9e00e84f9887c796a7b5ffdacf218151fee28512 (patch) | |
| tree | 2598a1cb2e2c4646faa7cc51c126da9179292ff9 /lib/libc/stdlib/malloc.c | |
| parent | 3e7102ecac14373c87cae51b6f764de409219f46 (diff) | |
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 (limited to 'lib/libc/stdlib/malloc.c')
| -rw-r--r-- | lib/libc/stdlib/malloc.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c index 52e5ae97b58..3b3245e82b3 100644 --- a/lib/libc/stdlib/malloc.c +++ b/lib/libc/stdlib/malloc.c @@ -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 @@ malloc(size_t size) 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 @@ realloc(void *ptr, size_t size) 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; |
