* @brief Allocate a block of memory with a minimum of 'size' bytes. * * @param size is the minimum size of the requested block in bytes. * * @return the pointer to allocated memory or NULL if no free memory was found. */
| 852 | * @return the pointer to allocated memory or NULL if no free memory was found. |
| 853 | */ |
| 854 | rt_weak void *rt_malloc(rt_size_t size) |
| 855 | { |
| 856 | rt_base_t level; |
| 857 | void *ptr; |
| 858 | |
| 859 | /* Enter critical zone */ |
| 860 | level = _heap_lock(); |
| 861 | /* allocate memory block from system heap */ |
| 862 | ptr = _MEM_MALLOC(size); |
| 863 | /* Exit critical zone */ |
| 864 | _heap_unlock(level); |
| 865 | /* call 'rt_malloc' hook */ |
| 866 | RT_OBJECT_HOOK_CALL(rt_malloc_hook, (&ptr, size)); |
| 867 | return ptr; |
| 868 | } |
| 869 | RTM_EXPORT(rt_malloc); |
| 870 | |
| 871 | /** |