MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / mem_malloc

Function mem_malloc

components/net/lwip/lwip-2.1.2/src/core/mem.c:206–221  ·  view source on GitHub ↗

* Allocate a block of memory with a minimum of 'size' bytes. * * @param size is the minimum size of the requested block in bytes. * @return pointer to allocated memory or NULL if no free memory was found. * * Note that the returned value must always be aligned (as defined by MEM_ALIGNMENT). */

Source from the content-addressed store, hash-verified

204 * Note that the returned value must always be aligned (as defined by MEM_ALIGNMENT).
205 */
206void *
207mem_malloc(mem_size_t size)
208{
209 void *ret = mem_clib_malloc(size + MEM_LIBC_STATSHELPER_SIZE);
210 if (ret == NULL) {
211 MEM_STATS_INC_LOCKED(err);
212 } else {
213 LWIP_ASSERT("malloc() must return aligned memory", LWIP_MEM_ALIGN(ret) == ret);
214#if LWIP_STATS && MEM_STATS
215 *(mem_size_t *)ret = size;
216 ret = (u8_t *)ret + MEM_LIBC_STATSHELPER_SIZE;
217 MEM_STATS_INC_USED_LOCKED(used, size);
218#endif
219 }
220 return ret;
221}
222
223/** Put memory back on the heap
224 *

Callers 15

pbuf_allocFunction · 0.70
mem_callocFunction · 0.70
do_memp_malloc_pool_fnFunction · 0.70
test_mem.cFile · 0.50
malloc_keep_xFunction · 0.50
START_TESTFunction · 0.50
test_sockets_msgapi_tcpFunction · 0.50
dhcp6_get_structFunction · 0.50

Calls 5

mem_to_ptrFunction · 0.85
ptr_to_memFunction · 0.85
sys_mutex_lockFunction · 0.50
sys_mutex_unlockFunction · 0.50

Tested by 7

malloc_keep_xFunction · 0.40
START_TESTFunction · 0.40
test_sockets_msgapi_tcpFunction · 0.40