| 53 | |
| 54 | #undef malloc |
| 55 | FAR void *malloc(size_t size) |
| 56 | { |
| 57 | #if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL) |
| 58 | /* Use memalign() because it implements the sbrk() logic */ |
| 59 | |
| 60 | return memalign(sizeof(FAR void *), size); |
| 61 | #else |
| 62 | FAR void *ret; |
| 63 | |
| 64 | /* Use mm_malloc() because it implements the clear */ |
| 65 | |
| 66 | ret = mm_malloc(USR_HEAP, size); |
| 67 | if (ret == NULL) |
| 68 | { |
| 69 | set_errno(ENOMEM); |
| 70 | } |
| 71 | else |
| 72 | { |
| 73 | mm_notify_pressure(mm_heapfree(USR_HEAP), |
| 74 | mm_heapfree_largest(USR_HEAP)); |
| 75 | } |
| 76 | |
| 77 | return ret; |
| 78 | #endif |
| 79 | } |
no test coverage detected