Lines Matching refs:heap
44 static rt_size_t max_block(struct rt_small_mem *heap) in max_block() argument
49 for (mem = (struct rt_small_mem_item *)heap->heap_ptr; in max_block()
50 mem != heap->heap_end; in max_block()
51 mem = (struct rt_small_mem_item *)&heap->heap_ptr[mem->next]) in max_block()
55 size = MEM_SIZE(heap, mem); in max_block()
86 struct rt_small_mem *heap; in mem_functional_test() local
95 heap = (struct rt_small_mem *)rt_smem_init("mem_tc", buf, TEST_MEM_SIZE); in mem_functional_test()
97 total_size = max_block(heap); in mem_functional_test()
106 ctx.size = max_block(heap); in mem_functional_test()
107 ctx.ptr = rt_smem_alloc(&heap->parent, ctx.size); in mem_functional_test()
112 uassert_int_equal(max_block(heap), total_size); in mem_functional_test()
125 ctx[i].size = max_block(heap) / (sizeof(ctx) / sizeof(ctx[0]) - i); in mem_functional_test()
126 ctx[i].ptr = rt_smem_alloc(&heap->parent, ctx[i].size); in mem_functional_test()
131 uassert_int_equal(max_block(heap), 0); in mem_functional_test()
143 uassert_true(max_block(heap) >= max_free); in mem_functional_test()
146 uassert_int_equal(max_block(heap), total_size); in mem_functional_test()
159 ctx[i].size = max_block(heap) / (sizeof(ctx) / sizeof(ctx[0]) - i); in mem_functional_test()
160 ctx[i].ptr = rt_smem_alloc(&heap->parent, ctx[i].size); in mem_functional_test()
165 uassert_int_equal(max_block(heap), 0); in mem_functional_test()
178 uassert_true(max_block(heap) >= ctx[0].size); in mem_functional_test()
189 uassert_true(max_block(heap) >= max_free); in mem_functional_test()
193 uassert_int_equal(max_block(heap), total_size); in mem_functional_test()
200 ctx[0].size = max_block(heap) / 3; in mem_functional_test()
201 ctx[0].ptr = rt_smem_alloc(&heap->parent, ctx[0].size); in mem_functional_test()
207 ctx[1].ptr = rt_smem_alloc(&heap->parent, ctx[1].size); in mem_functional_test()
211 uassert_true(max_block(heap) > ctx[0].size); in mem_functional_test()
214 ctx[2].size = max_block(heap); in mem_functional_test()
215 ctx[2].ptr = rt_smem_realloc(&heap->parent, ctx[0].ptr, ctx[2].size); in mem_functional_test()
227 uassert_int_equal(max_block(heap), total_size); in mem_functional_test()
235 ctx.size = max_block(heap) / 2; in mem_functional_test()
236 ctx.ptr = rt_smem_alloc(&heap->parent, ctx.size); in mem_functional_test()
241 max_free = max_block(heap); in mem_functional_test()
244 …uassert_int_equal((rt_ubase_t)rt_smem_realloc(&heap->parent, ctx.ptr, ctx.size), (rt_ubase_t)ctx.p… in mem_functional_test()
246 uassert_true(max_block(heap) > max_free); in mem_functional_test()
251 uassert_int_equal(max_block(heap), total_size); in mem_functional_test()
259 ctx.size = max_block(heap) / 2; in mem_functional_test()
260 ctx.ptr = rt_smem_alloc(&heap->parent, ctx.size); in mem_functional_test()
265 max_free = max_block(heap); in mem_functional_test()
267 …uassert_int_equal((rt_ubase_t)rt_smem_realloc(&heap->parent, ctx.ptr, ctx.size), (rt_ubase_t)ctx.p… in mem_functional_test()
269 uassert_true(max_block(heap) == max_free); in mem_functional_test()
274 uassert_int_equal(max_block(heap), total_size); in mem_functional_test()
277 rt_smem_detach(&heap->parent); in mem_functional_test()
306 struct rt_small_mem *heap; in mem_alloc_test() local
320 heap = (struct rt_small_mem *)rt_smem_init("mem_tc", buf, TEST_MEM_SIZE); in mem_alloc_test()
321 total_size = max_block(heap); in mem_alloc_test()
336 ctx = rt_smem_alloc(&heap->parent, size); in mem_alloc_test()
411 uassert_int_equal(max_block(heap), total_size); in mem_alloc_test()
413 rt_smem_detach(&heap->parent); in mem_alloc_test()
441 struct rt_small_mem *heap; in mem_realloc_test() local
458 heap = (struct rt_small_mem *)rt_smem_init("mem_tc", buf, TEST_MEM_SIZE); in mem_realloc_test()
459 total_size = max_block(heap); in mem_realloc_test()
463 head.ctx_tab = rt_smem_alloc(&heap->parent, size); in mem_realloc_test()
477 ctx = rt_smem_realloc(&heap->parent, head.ctx_tab[idx], size); in mem_realloc_test()
503 rt_smem_realloc(&heap->parent, ctx, 0); in mem_realloc_test()
559 rt_smem_realloc(&heap->parent, ctx, 0); in mem_realloc_test()
562 uassert_int_not_equal(max_block(heap), total_size); in mem_realloc_test()
564 rt_smem_detach(&heap->parent); in mem_realloc_test()