Lines Matching full:size

13  * 2017-07-14     armink       fix rt_realloc issue when new size is 0
60 static void (*rt_malloc_hook)(void *ptr, rt_size_t size);
75 void rt_malloc_sethook(void (*hook)(void *ptr, rt_size_t size)) in rt_malloc_sethook() argument
216 /* calculate the aligned memory size */ in rt_system_heap_init()
230 RT_DEBUG_LOG(RT_DEBUG_MEM, ("mem init, heap begin address 0x%x, size %d\n", in rt_system_heap_init()
266 * Allocate a block of memory with a minimum of 'size' bytes.
268 * @param size is the minimum size of the requested block in bytes.
272 void *rt_malloc(rt_size_t size) in rt_malloc() argument
277 if (size == 0) in rt_malloc()
282 if (size != RT_ALIGN(size, RT_ALIGN_SIZE)) in rt_malloc()
283 RT_DEBUG_LOG(RT_DEBUG_MEM, ("malloc size %d, but align to %d\n", in rt_malloc()
284 size, RT_ALIGN(size, RT_ALIGN_SIZE))); in rt_malloc()
286 RT_DEBUG_LOG(RT_DEBUG_MEM, ("malloc size %d\n", size)); in rt_malloc()
288 /* alignment size */ in rt_malloc()
289 size = RT_ALIGN(size, RT_ALIGN_SIZE); in rt_malloc()
291 if (size > mem_size_aligned) in rt_malloc()
299 if (size < MIN_SIZE_ALIGNED) in rt_malloc()
300 size = MIN_SIZE_ALIGNED; in rt_malloc()
306 ptr < mem_size_aligned - size; in rt_malloc()
311 if ((!mem->used) && (mem->next - (ptr + SIZEOF_STRUCT_MEM)) >= size) in rt_malloc()
314 * mem->next - (ptr + SIZEOF_STRUCT_MEM) gives us the 'user data size' of mem */ in rt_malloc()
317 (size + SIZEOF_STRUCT_MEM + MIN_SIZE_ALIGNED)) in rt_malloc()
323 * mem->next - (ptr + (2*SIZEOF_STRUCT_MEM)) == size, in rt_malloc()
329 ptr2 = ptr + SIZEOF_STRUCT_MEM + size; in rt_malloc()
350 used_mem += (size + SIZEOF_STRUCT_MEM); in rt_malloc()
390 RT_ASSERT((rt_ubase_t)mem + SIZEOF_STRUCT_MEM + size <= (rt_ubase_t)heap_end); in rt_malloc()
395 ("allocate memory at 0x%x, size: %d\n", in rt_malloc()
400 (((void *)((rt_uint8_t *)mem + SIZEOF_STRUCT_MEM)), size)); in rt_malloc()
417 * @param newsize the required new size
423 rt_size_t size; in rt_realloc() local
430 /* alignment size */ in rt_realloc()
462 size = mem->next - ptr - SIZEOF_STRUCT_MEM; in rt_realloc()
463 if (size == newsize) in rt_realloc()
465 /* the size is the same as */ in rt_realloc()
471 if (newsize + SIZEOF_STRUCT_MEM + MIN_SIZE < size) in rt_realloc()
475 used_mem -= (size - newsize); in rt_realloc()
505 rt_memcpy(nmem, rmem, size < newsize ? size : newsize); in rt_realloc()
515 * that are size bytes of memory each and returns a pointer to the allocated
521 * @param size size of the objects to allocate
525 void *rt_calloc(rt_size_t count, rt_size_t size) in rt_calloc() argument
529 /* allocate 'count' objects of size 'size' */ in rt_calloc()
530 p = rt_malloc(count * size); in rt_calloc()
534 rt_memset(p, 0, count * size); in rt_calloc()
573 ("release memory 0x%x, size: %d\n", in rt_free()
659 rt_kprintf(" size: %d\n", mem->next - position - SIZEOF_STRUCT_MEM); in FINSH_FUNCTION_EXPORT()
681 int size; in memtrace() local
685 size = mem->next - position - SIZEOF_STRUCT_MEM; in memtrace()
686 if (size < 1024) in memtrace()
687 rt_kprintf("%5d", size); in memtrace()
688 else if (size < 1024 * 1024) in memtrace()
689 rt_kprintf("%4dK", size / 1024); in memtrace()
691 rt_kprintf("%4dM", size / (1024 * 1024)); in memtrace()