mirror of
https://github.com/apache/nuttx.git
synced 2025-12-13 06:14:40 +08:00
malloc: set errno to ENOMEM when malloc fail
fix LTP case ltp_threads_pthread_cond_init_s_c error: "Test ltp_threads_pthread_cond_init_s_c unresolved: got 38 (Invalid system call number) on line 236 (Memory not full)" Signed-off-by: yangyalei <yangyalei@xiaomi.com> ltp: fix review questions Signed-off-by: yangyalei <yangyalei@xiaomi.com>
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <nuttx/mm/mm.h>
|
||||
|
||||
#include "umm_heap/umm_heap.h"
|
||||
@@ -57,8 +57,16 @@ FAR void *malloc(size_t size)
|
||||
|
||||
return memalign(sizeof(FAR void *), size);
|
||||
#else
|
||||
FAR void *ret;
|
||||
|
||||
/* Use mm_malloc() because it implements the clear */
|
||||
|
||||
return mm_malloc(USR_HEAP, size);
|
||||
ret = mm_malloc(USR_HEAP, size);
|
||||
if (!ret)
|
||||
{
|
||||
set_errno(ENOMEM);
|
||||
}
|
||||
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user