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

Function memo_tests

malloc2/tests.c:4–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2#include "malloc2.h"
3
4static void memo_tests() {
5 struct hc_memo_alloc a;
6 hc_memo_alloc_init(&a, &hc_malloc_default);
7
8 int *ip1 = hc_acquire(&a.malloc, sizeof(int));
9
10 long *lp = hc_acquire(&a.malloc, sizeof(long));
11 assert((int *)lp != ip1);
12 *lp = 42;
13
14 hc_release(&a.malloc, ip1);
15 int *ip2 = hc_acquire(&a.malloc, sizeof(int));
16 assert(ip2 == ip1);
17 *ip2 = 42;
18
19 int *ip3 = hc_acquire(&a.malloc, sizeof(int));
20 assert(ip3 != ip1);
21 *ip3 = 42;
22
23 hc_release(&a.malloc, lp);
24 hc_release(&a.malloc, ip2);
25 hc_release(&a.malloc, ip3);
26
27 hc_memo_alloc_deinit(&a);
28}
29
30static void slab_tests() {
31 struct hc_slab_alloc a;

Callers 1

malloc2_testsFunction · 0.85

Calls 2

hc_memo_alloc_initFunction · 0.85
hc_memo_alloc_deinitFunction · 0.85

Tested by

no test coverage detected