Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/stdlib Make sure errno is set to ENOMEM if we retur...



details:   https://anonhg.NetBSD.org/src/rev/2af86456608d
branches:  trunk
changeset: 474506:2af86456608d
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Jul 08 22:18:06 1999 +0000

description:
Make sure errno is set to ENOMEM if we return NULL.

diffstat:

 lib/libc/stdlib/malloc.c |  16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diffs (36 lines):

diff -r fcb6a8affe3c -r 2af86456608d lib/libc/stdlib/malloc.c
--- a/lib/libc/stdlib/malloc.c  Thu Jul 08 21:14:26 1999 +0000
+++ b/lib/libc/stdlib/malloc.c  Thu Jul 08 22:18:06 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: malloc.c,v 1.23 1999/07/05 22:14:38 thorpej Exp $      */
+/*     $NetBSD: malloc.c,v 1.24 1999/07/08 22:18:06 thorpej Exp $      */
 
 /*
  * ----------------------------------------------------------------------------
@@ -1082,8 +1082,11 @@
     UTRACE(0, size, r);
     malloc_active--;
     THREAD_UNLOCK();
-    if (malloc_xmalloc && !r)
-       wrterror("out of memory.\n");
+    if (r == NULL) {
+       if (malloc_xmalloc)
+           wrterror("out of memory.\n");
+       errno = ENOMEM;
+    }
     return (r);
 }
 
@@ -1134,7 +1137,10 @@
     UTRACE(ptr, size, r);
     malloc_active--;
     THREAD_UNLOCK();
-    if (malloc_xmalloc && !r)
-       wrterror("out of memory.\n");
+    if (r == NULL) {
+       if (malloc_xmalloc)
+           wrterror("out of memory.\n");
+       errno = ENOMEM;
+    }
     return (r);
 }



Home | Main Index | Thread Index | Old Index