MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / test_mp_static_alloc_free

Function test_mp_static_alloc_free

src/utest/mempool_tc.c:45–69  ·  view source on GitHub ↗

Allocation and free test for static */

Source from the content-addressed store, hash-verified

43
44/* Allocation and free test for static */
45static void test_mp_static_alloc_free(void)
46{
47 void *block1, *block2, *block3;
48
49 /* Allocate blocks */
50 block1 = rt_mp_alloc(&mp_static, 0);
51 uassert_not_null(block1);
52
53 block2 = rt_mp_alloc(&mp_static, 0);
54 uassert_not_null(block2);
55
56 block3 = rt_mp_alloc(&mp_static, 0);
57 uassert_not_null(block3);
58
59 /* Check free count */
60 uassert_true(mp_static.block_free_count == MEMPOOL_BLOCK_COUNT - 3);
61
62 /* Free blocks */
63 rt_mp_free(block1);
64 rt_mp_free(block2);
65 rt_mp_free(block3);
66
67 /* Check free count */
68 uassert_true(mp_static.block_free_count == MEMPOOL_BLOCK_COUNT);
69}
70
71/* Allocation and free test for dynamic */
72static void test_mp_dynamic_alloc_free(void)

Callers

nothing calls this directly

Calls 2

rt_mp_allocFunction · 0.85
rt_mp_freeFunction · 0.85

Tested by

no test coverage detected