* @brief This function will change the size of previously allocated memory block. * * @param ptr is the pointer to memory allocated by rt_malloc. * * @param newsize is the required new size. * * @return the changed memory block address. */
| 878 | * @return the changed memory block address. |
| 879 | */ |
| 880 | rt_weak void *rt_realloc(void *ptr, rt_size_t newsize) |
| 881 | { |
| 882 | rt_base_t level; |
| 883 | void *nptr; |
| 884 | |
| 885 | /* Entry hook */ |
| 886 | RT_OBJECT_HOOK_CALL(rt_realloc_entry_hook, (&ptr, newsize)); |
| 887 | /* Enter critical zone */ |
| 888 | level = _heap_lock(); |
| 889 | /* Change the size of previously allocated memory block */ |
| 890 | nptr = _MEM_REALLOC(ptr, newsize); |
| 891 | /* Exit critical zone */ |
| 892 | _heap_unlock(level); |
| 893 | /* Exit hook */ |
| 894 | RT_OBJECT_HOOK_CALL(rt_realloc_exit_hook, (&nptr, newsize)); |
| 895 | return nptr; |
| 896 | } |
| 897 | RTM_EXPORT(rt_realloc); |
| 898 | |
| 899 | /** |