Always set errno to ENOMEM when returning 0 from malloc() or realloc().

Approved by:	phk
This commit is contained in:
Dag-Erling Smørgrav 1999-07-07 19:54:08 +00:00
parent be74589b43
commit c58b5cffa1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=48670

View File

@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
* $Id: malloc.c,v 1.43 1998/09/30 06:13:59 jb Exp $
* $Id: malloc.c,v 1.44 1999/03/28 14:16:05 phk Exp $
*
*/
@ -1081,6 +1081,8 @@ malloc(size_t size)
THREAD_UNLOCK();
if (malloc_xmalloc && !r)
wrterror("out of memory.\n");
if (!r)
errno = ENOMEM;
return (r);
}
@ -1133,6 +1135,8 @@ realloc(void *ptr, size_t size)
THREAD_UNLOCK();
if (malloc_xmalloc && !r)
wrterror("out of memory.\n");
if (!r)
errno = ENOMEM;
return (r);
}