Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/newlib
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2005-10-07 22:07:26 +0400
committerJeff Johnston <jjohnstn@redhat.com>2005-10-07 22:07:26 +0400
commitf011605a90b94eb144cb7e9923088fa6fd4d377a (patch)
treeade24b1bb4fe71fec6821e7d5ee8a1a50295c098 /newlib
parentbc037f3a51648667cd368e511a24f8a11eaa9be9 (diff)
2005-10-07 Bob Wilson <bob.wilson@acm.org>
* libc/stdlib/mallocr.c (mALLOc, rEALLOCc, mEMALIGn): Set errno to ENOMEM on failure.
Diffstat (limited to 'newlib')
-rw-r--r--newlib/ChangeLog5
-rw-r--r--newlib/libc/stdlib/mallocr.c12
2 files changed, 17 insertions, 0 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index 47ebb843e..f81f154a9 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,8 @@
+2005-10-07 Bob Wilson <bob.wilson@acm.org>
+
+ * libc/stdlib/mallocr.c (mALLOc, rEALLOCc, mEMALIGn): Set errno
+ to ENOMEM on failure.
+
2005-10-06 Ralf Corsepius <ralf.corsepius@rtems.org>
* libc/include/stdint.h: Add [u]int_fast<N>_t types.
diff --git a/newlib/libc/stdlib/mallocr.c b/newlib/libc/stdlib/mallocr.c
index 02f6a5d15..cfa25545f 100644
--- a/newlib/libc/stdlib/mallocr.c
+++ b/newlib/libc/stdlib/mallocr.c
@@ -268,6 +268,7 @@ extern "C" {
#include <stdio.h> /* needed for malloc_stats */
#include <limits.h> /* needed for overflow checks */
+#include <errno.h> /* needed to set errno to ENOMEM */
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
@@ -335,6 +336,7 @@ extern void __malloc_unlock();
#define RDECL struct _reent *reent_ptr;
#endif
+#define RERRNO reent_ptr->_errno
#define RCALL reent_ptr,
#define RONECALL reent_ptr
@@ -344,6 +346,7 @@ extern void __malloc_unlock();
#define RARG
#define RONEARG
#define RDECL
+#define RERRNO errno
#define RCALL
#define RONECALL
@@ -2341,7 +2344,10 @@ Void_t* mALLOc(RARG bytes) RDECL size_t bytes;
/* Check for overflow and just fail, if so. */
if (nb > INT_MAX || nb < bytes)
+ {
+ RERRNO = ENOMEM;
return 0;
+ }
MALLOC_LOCK;
@@ -2804,7 +2810,10 @@ Void_t* rEALLOc(RARG oldmem, bytes) RDECL Void_t* oldmem; size_t bytes;
/* Check for overflow and just fail, if so. */
if (nb > INT_MAX || nb < bytes)
+ {
+ RERRNO = ENOMEM;
return 0;
+ }
#if HAVE_MMAP
if (chunk_is_mmapped(oldp))
@@ -3037,7 +3046,10 @@ Void_t* mEMALIGn(RARG alignment, bytes) RDECL size_t alignment; size_t bytes;
/* Check for overflow. */
if (nb > INT_MAX || nb < bytes)
+ {
+ RERRNO = ENOMEM;
return 0;
+ }
m = (char*)(mALLOc(RCALL nb + alignment + MINSIZE));