Add missing clean-up code.
[calfbox.git] / fifo.c
blob5c9852bb63128f0839c8970c0cc3f7a0912e8030
1 #include "fifo.h"
2 #include <malloc.h>
4 struct cbox_fifo *cbox_fifo_new(uint32_t size)
6 struct cbox_fifo *fifo = calloc(1, sizeof(struct cbox_fifo) + size);
7 if (!fifo)
8 return NULL;
9 fifo->data = (uint8_t *)(fifo + 1);
10 fifo->size = size;
11 fifo->write_count = 0;
12 fifo->write_offset= 0;
13 fifo->read_count = 0;
14 fifo->read_offset = 0;
15 return fifo;
18 void cbox_fifo_destroy(struct cbox_fifo *fifo)
20 free(fifo);