MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / thd_start

Function thd_start

deps/jemalloc/test/integration/allocated.c:11–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9 ;
10
11void *
12thd_start(void *arg) {
13 int err;
14 void *p;
15 uint64_t a0, a1, d0, d1;
16 uint64_t *ap0, *ap1, *dp0, *dp1;
17 size_t sz, usize;
18
19 sz = sizeof(a0);
20 if ((err = mallctl("thread.allocated", (void *)&a0, &sz, NULL, 0))) {
21 if (err == ENOENT) {
22 goto label_ENOENT;
23 }
24 test_fail("%s(): Error in mallctl(): %s", __func__,
25 strerror(err));
26 }
27 sz = sizeof(ap0);
28 if ((err = mallctl("thread.allocatedp", (void *)&ap0, &sz, NULL, 0))) {
29 if (err == ENOENT) {
30 goto label_ENOENT;
31 }
32 test_fail("%s(): Error in mallctl(): %s", __func__,
33 strerror(err));
34 }
35 assert_u64_eq(*ap0, a0,
36 "\"thread.allocatedp\" should provide a pointer to internal "
37 "storage");
38
39 sz = sizeof(d0);
40 if ((err = mallctl("thread.deallocated", (void *)&d0, &sz, NULL, 0))) {
41 if (err == ENOENT) {
42 goto label_ENOENT;
43 }
44 test_fail("%s(): Error in mallctl(): %s", __func__,
45 strerror(err));
46 }
47 sz = sizeof(dp0);
48 if ((err = mallctl("thread.deallocatedp", (void *)&dp0, &sz, NULL,
49 0))) {
50 if (err == ENOENT) {
51 goto label_ENOENT;
52 }
53 test_fail("%s(): Error in mallctl(): %s", __func__,
54 strerror(err));
55 }
56 assert_u64_eq(*dp0, d0,
57 "\"thread.deallocatedp\" should provide a pointer to internal "
58 "storage");
59
60 p = malloc(1);
61 assert_ptr_not_null(p, "Unexpected malloc() error");
62
63 sz = sizeof(a1);
64 mallctl("thread.allocated", (void *)&a1, &sz, NULL, 0);
65 sz = sizeof(ap1);
66 mallctl("thread.allocatedp", (void *)&ap1, &sz, NULL, 0);
67 assert_u64_eq(*ap1, a1,
68 "Dereferenced \"thread.allocatedp\" value should equal "

Callers 1

allocated.cFile · 0.70

Calls 4

mallocFunction · 0.85
freeFunction · 0.85
test_failFunction · 0.50
test_skipFunction · 0.50

Tested by

no test coverage detected