Lines Matching +full:swap +full:- +full:bytes

2  * SPDX-License-Identifier: Apache-2.0
12 heap->nheaps = 0; in sys_multi_heap_init()
13 heap->choice = choice_fn; in sys_multi_heap_init()
19 __ASSERT_NO_MSG(mheap->nheaps < ARRAY_SIZE(mheap->heaps)); in sys_multi_heap_add_heap()
21 mheap->heaps[mheap->nheaps].heap = heap; in sys_multi_heap_add_heap()
22 mheap->heaps[mheap->nheaps++].user_data = user_data; in sys_multi_heap_add_heap()
25 for (int i = 0; i < mheap->nheaps; i++) { in sys_multi_heap_add_heap()
26 struct sys_multi_heap_rec swap; in sys_multi_heap_add_heap() local
27 int lowest = -1; in sys_multi_heap_add_heap()
30 for (int j = i; j < mheap->nheaps; j++) { in sys_multi_heap_add_heap()
31 uintptr_t haddr = (uintptr_t)mheap->heaps[j].heap->heap; in sys_multi_heap_add_heap()
38 swap = mheap->heaps[i]; in sys_multi_heap_add_heap()
39 mheap->heaps[i] = mheap->heaps[lowest]; in sys_multi_heap_add_heap()
40 mheap->heaps[lowest] = swap; in sys_multi_heap_add_heap()
44 void *sys_multi_heap_alloc(struct sys_multi_heap *mheap, void *cfg, size_t bytes) in sys_multi_heap_alloc() argument
46 return mheap->choice(mheap, cfg, 0, bytes); in sys_multi_heap_alloc()
50 void *cfg, size_t align, size_t bytes) in sys_multi_heap_aligned_alloc() argument
52 return mheap->choice(mheap, cfg, align, bytes); in sys_multi_heap_aligned_alloc()
69 for (i = 0; i < mheap->nheaps; i++) { in sys_multi_heap_get_heap()
70 haddr = (uintptr_t)mheap->heaps[i].heap->heap; in sys_multi_heap_get_heap()
78 * FIXME: return -ENOENT when a proper heap is not found in sys_multi_heap_get_heap()
80 return &mheap->heaps[i-1]; in sys_multi_heap_get_heap()
91 sys_heap_free(heap->heap, block); in sys_multi_heap_free()
96 void *ptr, size_t align, size_t bytes) in sys_multi_heap_aligned_realloc() argument
100 return sys_multi_heap_aligned_alloc(mheap, cfg, align, bytes); in sys_multi_heap_aligned_realloc()
102 if (bytes == 0) { in sys_multi_heap_aligned_realloc()
112 void *new_ptr = sys_heap_aligned_realloc(rec->heap, ptr, align, bytes); in sys_multi_heap_aligned_realloc()
118 size_t old_size = sys_heap_usable_size(rec->heap, ptr); in sys_multi_heap_aligned_realloc()
121 new_ptr = sys_multi_heap_aligned_alloc(mheap, cfg, align, bytes); in sys_multi_heap_aligned_realloc()
123 memcpy(new_ptr, ptr, MIN(old_size, bytes)); in sys_multi_heap_aligned_realloc()