MCPcopy Create free account
hub / github.com/codr7/hacktical-c / slab_tests

Function slab_tests

malloc2/tests.c:30–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28}
29
30static void slab_tests() {
31 struct hc_slab_alloc a;
32 hc_slab_alloc_init(&a, &hc_malloc_default, 2 * sizeof(int));
33 assert(a.slab_size == 2 * sizeof(int));
34
35 const int *p1 = hc_acquire(&a.malloc, sizeof(int));
36 const int *p2 = hc_acquire(&a.malloc, sizeof(int));
37 assert(p2 == p1 + 1);
38
39 const int *p3 = hc_acquire(&a.malloc, sizeof(int));
40 assert(p3 > p2 + 1);
41
42 const int *p4 = hc_acquire(&a.malloc, 10 * sizeof(int));
43 assert(p4 > p3 + 1);
44
45 hc_slab_alloc_deinit(&a);
46}
47
48void malloc2_tests() {
49 memo_tests();

Callers 1

malloc2_testsFunction · 0.85

Calls 2

hc_slab_alloc_initFunction · 0.85
hc_slab_alloc_deinitFunction · 0.85

Tested by

no test coverage detected