diff options
| author | bernard.xiong <[email protected]> | 2010-10-14 09:38:03 +0000 |
|---|---|---|
| committer | bernard.xiong <[email protected]> | 2010-10-14 09:38:03 +0000 |
| commit | 9e324032b6ddaa25086af371a43d80eea3aa23fe (patch) | |
| tree | 2427072974b2e42b2636cc1da017586a96009332 /src/mem.c | |
| parent | 8a43cbc5b9a5ab9065e77d24e8963089cc1a12a9 (diff) | |
fix rt_realloc issue when realloc a NULL pointer.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1010 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'src/mem.c')
| -rw-r--r-- | src/mem.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -13,6 +13,7 @@ * 2010-06-09 Bernard fix the end stub of heap * fix memory check in rt_realloc function * 2010-07-13 Bernard fix RT_ALIGN issue found by kuronca + * 2010-10-14 Bernard fix rt_realloc issue when realloc a NULL pointer. */ /* @@ -367,6 +368,10 @@ void *rt_realloc(void *rmem, rt_size_t newsize) return RT_NULL; } + /* allocate a new memory block */ + if (rmem == RT_NULL) + return rt_malloc(newsize); + rt_sem_take(&heap_sem, RT_WAITING_FOREVER); if ((rt_uint8_t *)rmem < (rt_uint8_t *)heap_ptr || |
