summaryrefslogtreecommitdiff
path: root/examples/dte/block.c
blob: 3953571b3e447797c808f59d7836c901709a2c50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <stdlib.h>
#include "block.h"
#include "util/xmalloc.h"

Block *block_new(size_t alloc)
{
    Block *blk = xnew0(Block, 1);
    alloc = round_size_to_next_multiple(alloc, BLOCK_ALLOC_MULTIPLE);
    blk->data = xmalloc(alloc);
    blk->alloc = alloc;
    return blk;
}

void block_free(Block *blk)
{
    list_del(&blk->node);
    free(blk->data);
    free(blk);
}