MCPcopy Create free account
hub / github.com/acl-dev/acl / fifo_test

Function fifo_test

lib_acl/samples/fifo/main.cpp:9–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7#endif
8
9static void fifo_test(bool use_slice)
10{
11 ACL_FIFO *fifo;
12 int i;
13 char *ptr;
14 ACL_SLICE_POOL *slice;
15
16 if (use_slice)
17 slice = acl_slice_pool_create(10, 100,
18 ACL_SLICE_FLAG_GC2 | ACL_SLICE_FLAG_RTGC_OFF);
19 else
20 slice = NULL;
21
22 fifo = acl_fifo_new1(slice);
23
24 for (i = 0; i < 20; i++) {
25 if (slice)
26 ptr = (char*) acl_slice_pool_alloc(__FILE__, __LINE__,
27 slice, 100);
28 else
29 ptr = (char*) acl_mymalloc(100);
30 snprintf(ptr, 100, "test:%d", i);
31 (void) acl_fifo_push(fifo, ptr);
32 printf(">>>ptr: %s\n", ptr);
33 }
34
35 while (1) {
36 ptr = (char*) acl_fifo_pop(fifo);
37 if (ptr == NULL)
38 break;
39 printf("fifo pop: %s\n", ptr);
40 if (!slice)
41 acl_myfree(ptr);
42 }
43
44 if (slice == NULL)
45 acl_fifo_free(fifo, acl_myfree_fn);
46 else
47 acl_slice_pool_destroy(slice);
48}
49
50int main(int argc acl_unused, char *argv[] acl_unused)
51{

Callers 1

mainFunction · 0.85

Calls 5

acl_slice_pool_createFunction · 0.85
acl_fifo_new1Function · 0.85
acl_slice_pool_allocFunction · 0.85
acl_fifo_freeFunction · 0.85
acl_slice_pool_destroyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…