Lines Matching refs:ptr

60     void *ptr;  member
150 static struct free_heap_chunk *heap_create_free_chunk(void *ptr, size_t len, bool allow_debug) { in heap_create_free_chunk() argument
156 memset(ptr, FREE_FILL, len); in heap_create_free_chunk()
159 struct free_heap_chunk *chunk = (struct free_heap_chunk *)ptr; in heap_create_free_chunk()
166 void *ptr; in miniheap_alloc() local
206 ptr = NULL; in miniheap_alloc()
213 ptr = chunk; in miniheap_alloc()
221 …struct free_heap_chunk *newchunk = heap_create_free_chunk((uint8_t *)ptr + size, chunk->len - size… in miniheap_alloc()
238 memset(ptr, ALLOC_FILL, size); in miniheap_alloc()
241 ptr = (void *)((addr_t)ptr + sizeof(struct alloc_struct_begin)); in miniheap_alloc()
245 ptr = (void *)ROUNDUP((addr_t)ptr, (addr_t)alignment); in miniheap_alloc()
248 struct alloc_struct_begin *as = (struct alloc_struct_begin *)ptr; in miniheap_alloc()
253 as->ptr = (void *)chunk; in miniheap_alloc()
261 as->padding_start = ((uint8_t *)ptr + original_size); in miniheap_alloc()
262 as->padding_size = (((addr_t)chunk + size) - ((addr_t)ptr + original_size)); in miniheap_alloc()
275 if (ptr == NULL && retry_count == 0) { in miniheap_alloc()
283 LTRACEF("returning ptr %p\n", ptr); in miniheap_alloc()
285 return ptr; in miniheap_alloc()
288 void *miniheap_realloc(void *ptr, size_t size) { in miniheap_realloc() argument
290 if (!ptr) in miniheap_realloc()
293 miniheap_free(ptr); in miniheap_realloc()
302 memcpy(p, ptr, size); // XXX wrong in miniheap_realloc()
303 miniheap_free(ptr); in miniheap_realloc()
308 void miniheap_free(void *ptr) { in miniheap_free() argument
309 if (!ptr) in miniheap_free()
312 LTRACEF("ptr %p\n", ptr); in miniheap_free()
315 struct alloc_struct_begin *as = (struct alloc_struct_begin *)ptr; in miniheap_free()
327 printf("free at %p scribbled outside the lines:\n", ptr); in miniheap_free()
335 LTRACEF("allocation was %zd bytes long at ptr %p\n", as->size, as->ptr); in miniheap_free()
338 heap_insert_free_chunk(heap_create_free_chunk(as->ptr, as->size, true)); in miniheap_free()
437 void miniheap_get_stats(struct miniheap_stats *ptr) { in miniheap_get_stats() argument
440 ptr->heap_start = theheap.base; in miniheap_get_stats()
441 ptr->heap_len = theheap.len; in miniheap_get_stats()
442 ptr->heap_free=0; in miniheap_get_stats()
443 ptr->heap_max_chunk = 0; in miniheap_get_stats()
448 ptr->heap_free += chunk->len; in miniheap_get_stats()
450 if (chunk->len > ptr->heap_max_chunk) { in miniheap_get_stats()
451 ptr->heap_max_chunk = chunk->len; in miniheap_get_stats()
455 ptr->heap_low_watermark = theheap.low_watermark; in miniheap_get_stats()
462 void *ptr = page_alloc(size / PAGE_SIZE, PAGE_ALLOC_ANY_ARENA); in heap_grow() local
463 if (!ptr) { in heap_grow()
468 LTRACEF("growing heap by 0x%zx bytes, new ptr %p\n", size, ptr); in heap_grow()
470 heap_insert_free_chunk(heap_create_free_chunk(ptr, size, true)); in heap_grow()
473 if ((uintptr_t)ptr < (uintptr_t)theheap.base || theheap.base == 0) in heap_grow()
474 theheap.base = ptr; in heap_grow()
476 uintptr_t endptr = (uintptr_t)ptr + size; in heap_grow()
484 void miniheap_init(void *ptr, size_t len) { in miniheap_init() argument
485 LTRACEF("ptr %p, len %zu\n", ptr, len); in miniheap_init()
494 if (((uintptr_t)ptr % sizeof(uintptr_t)) > 0) { in miniheap_init()
495 uintptr_t aligned_ptr = ROUNDUP((uintptr_t)ptr, sizeof(uintptr_t)); in miniheap_init()
497 DEBUG_ASSERT((aligned_ptr - (uintptr_t)ptr) < len); in miniheap_init()
499 len -= aligned_ptr - (uintptr_t)ptr; in miniheap_init()
500 ptr = (void *)aligned_ptr; in miniheap_init()
502 LTRACEF("(aligned) ptr %p, len %zu\n", ptr, len); in miniheap_init()
506 theheap.base = ptr; in miniheap_init()
513 heap_insert_free_chunk(heap_create_free_chunk(ptr, len, true)); in miniheap_init()