dte test coverage


Directory: ./
File: src/block.c
Date: 2024-12-21 16:03:22
Exec Total Coverage
Lines: 16 16 100.0%
Functions: 3 3 100.0%
Branches: 2 2 100.0%

Line Branch Exec Source
1 #include <stdlib.h>
2 #include "block.h"
3 #include "util/xmalloc.h"
4
5 enum {
6 BLOCK_ALLOC_MULTIPLE = 64
7 };
8
9 107 Block *block_new(size_t alloc)
10 {
11 107 Block *blk = xnew0(Block, 1);
12 107 alloc = round_size_to_next_multiple(alloc, BLOCK_ALLOC_MULTIPLE);
13 107 blk->data = xmalloc(alloc);
14 107 blk->alloc = alloc;
15 107 return blk;
16 }
17
18 220 void block_grow(Block *blk, size_t alloc)
19 {
20
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 216 times.
220 if (alloc > blk->alloc) {
21 4 blk->alloc = round_size_to_next_multiple(alloc, BLOCK_ALLOC_MULTIPLE);
22 4 blk->data = xrealloc(blk->data, blk->alloc);
23 }
24 220 }
25
26 3 void block_free(Block *blk)
27 {
28 3 list_remove(&blk->node);
29 3 free(blk->data);
30 3 free(blk);
31 3 }
32