Lines Matching refs:heap
15 void k_heap_init(struct k_heap *heap, void *mem, size_t bytes) in k_heap_init() argument
17 z_waitq_init(&heap->wait_q); in k_heap_init()
18 sys_heap_init(&heap->heap, mem, bytes); in k_heap_init()
20 SYS_PORT_TRACING_OBJ_INIT(k_heap, heap); in k_heap_init()
25 STRUCT_SECTION_FOREACH(k_heap, heap) { in statics_init()
40 if (lnkr_is_pinned((uint8_t *)heap) && in statics_init()
41 lnkr_is_pinned((uint8_t *)&heap->wait_q) && in statics_init()
42 lnkr_is_region_pinned((uint8_t *)heap->heap.init_mem, in statics_init()
43 heap->heap.init_bytes)) { in statics_init()
50 k_heap_init(heap, heap->heap.init_mem, heap->heap.init_bytes); in statics_init()
65 void *k_heap_aligned_alloc(struct k_heap *heap, size_t align, size_t bytes, in k_heap_aligned_alloc() argument
71 k_spinlock_key_t key = k_spin_lock(&heap->lock); in k_heap_aligned_alloc()
73 SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_heap, aligned_alloc, heap, timeout); in k_heap_aligned_alloc()
80 ret = sys_heap_aligned_alloc(&heap->heap, align, bytes); in k_heap_aligned_alloc()
90 SYS_PORT_TRACING_OBJ_FUNC_BLOCKING(k_heap, aligned_alloc, heap, timeout); in k_heap_aligned_alloc()
98 (void) z_pend_curr(&heap->lock, key, &heap->wait_q, timeout); in k_heap_aligned_alloc()
99 key = k_spin_lock(&heap->lock); in k_heap_aligned_alloc()
102 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_heap, aligned_alloc, heap, timeout, ret); in k_heap_aligned_alloc()
104 k_spin_unlock(&heap->lock, key); in k_heap_aligned_alloc()
108 void *k_heap_alloc(struct k_heap *heap, size_t bytes, k_timeout_t timeout) in k_heap_alloc() argument
110 SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_heap, alloc, heap, timeout); in k_heap_alloc()
112 void *ret = k_heap_aligned_alloc(heap, sizeof(void *), bytes, timeout); in k_heap_alloc()
114 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_heap, alloc, heap, timeout, ret); in k_heap_alloc()
119 void *k_heap_calloc(struct k_heap *heap, size_t num, size_t size, k_timeout_t timeout) in k_heap_calloc() argument
121 SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_heap, calloc, heap, timeout); in k_heap_calloc()
127 ret = k_heap_alloc(heap, bounds, timeout); in k_heap_calloc()
133 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_heap, calloc, heap, timeout, ret); in k_heap_calloc()
138 void *k_heap_realloc(struct k_heap *heap, void *ptr, size_t bytes, k_timeout_t timeout) in k_heap_realloc() argument
143 k_spinlock_key_t key = k_spin_lock(&heap->lock); in k_heap_realloc()
145 SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_heap, realloc, heap, ptr, bytes, timeout); in k_heap_realloc()
150 ret = sys_heap_aligned_realloc(&heap->heap, ptr, sizeof(void *), bytes); in k_heap_realloc()
158 (void) z_pend_curr(&heap->lock, key, &heap->wait_q, timeout); in k_heap_realloc()
159 key = k_spin_lock(&heap->lock); in k_heap_realloc()
162 SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_heap, realloc, heap, ptr, bytes, timeout, ret); in k_heap_realloc()
164 k_spin_unlock(&heap->lock, key); in k_heap_realloc()
168 void k_heap_free(struct k_heap *heap, void *mem) in k_heap_free() argument
170 k_spinlock_key_t key = k_spin_lock(&heap->lock); in k_heap_free()
172 sys_heap_free(&heap->heap, mem); in k_heap_free()
174 SYS_PORT_TRACING_OBJ_FUNC(k_heap, free, heap); in k_heap_free()
175 if (IS_ENABLED(CONFIG_MULTITHREADING) && (z_unpend_all(&heap->wait_q) != 0)) { in k_heap_free()
176 z_reschedule(&heap->lock, key); in k_heap_free()
178 k_spin_unlock(&heap->lock, key); in k_heap_free()