diff options
| author | bernard.xiong <[email protected]> | 2010-11-30 06:58:37 +0000 |
|---|---|---|
| committer | bernard.xiong <[email protected]> | 2010-11-30 06:58:37 +0000 |
| commit | 48738e864fad3c53437e5cf80d9d9b8a13d798ab (patch) | |
| tree | 0ffde89b90199a353ea33cce9bcb9ba4723d8224 /components/libc | |
| parent | e5eac973a87ec17a05d81e94229bca4997dfcc06 (diff) | |
set ENOMEM when malloc failed.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1156 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'components/libc')
| -rw-r--r-- | components/libc/newlib/syscalls.c | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/components/libc/newlib/syscalls.c b/components/libc/newlib/syscalls.c index 9960be97ab..9254cc7cea 100644 --- a/components/libc/newlib/syscalls.c +++ b/components/libc/newlib/syscalls.c @@ -195,18 +195,42 @@ _gettimeofday_r(struct _reent *ptr, struct timeval *__tp, void *__tzp) void *
_malloc_r (struct _reent *ptr, size_t size)
{
- return (void*)rt_malloc (size);
+ void* result;
+
+ result = (void*)rt_malloc (size);
+ if (result == RT_NULL)
+ {
+ ptr->_errno = ENOMEM;
+ }
+
+ return result;
}
void *
_realloc_r (struct _reent *ptr, void *old, size_t newlen)
{
- return (void*)rt_realloc (old, newlen);
+ void* result;
+
+ result = (void*)rt_realloc (old, newlen);
+ if (result == RT_NULL)
+ {
+ ptr->_errno = ENOMEM;
+ }
+
+ return result;
}
void *_calloc_r (struct _reent *ptr, size_t size, size_t len)
{
- return (void*)rt_calloc (size, len);
+ void* result;
+
+ result = (void*)rt_calloc (size, len);
+ if (result == RT_NULL)
+ {
+ ptr->_errno = ENOMEM;
+ }
+
+ return result;
}
void
@@ -215,19 +239,9 @@ _free_r (struct _reent *ptr, void *addr) rt_free (addr);
}
-#if 0
-void __assert(const char *file, int line, const char *failedexpr)
-{
- rt_kprintf("assertion \"%s\" failed: file \"%s\", line %d\n",
- failedexpr, file, line);
- RT_ASSERT(0);
-}
-#endif
-
void
_exit (int status)
{
rt_kprintf("thread:%s exit with %d\n", rt_thread_self()->name, status);
RT_ASSERT(0);
}
-
|
