about summary refs log tree commit diff stats
path: root/kernel.soso/fifobuffer.h
blob: 596cd33617bf41ef9f926a723498a4f393cf44e8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#ifndef FIFOBUFFER_H
#define FIFOBUFFER_H

#include "common.h"

typedef struct FifoBuffer {
    uint8* data;
    uint32 writeIndex;
    uint32 readIndex;
    uint32 capacity;
    uint32 usedBytes;
} FifoBuffer;

FifoBuffer* FifoBuffer_create(uint32 capacity);
void FifoBuffer_destroy(FifoBuffer* fifoBuffer);
void FifoBuffer_clear(FifoBuffer* fifoBuffer);
BOOL FifoBuffer_isEmpty(FifoBuffer* fifoBuffer);
uint32 FifoBuffer_getSize(FifoBuffer* fifoBuffer);
uint32 FifoBuffer_getCapacity(FifoBuffer* fifoBuffer);
uint32 FifoBuffer_getFree(FifoBuffer* fifoBuffer);
int32 FifoBuffer_enqueue(FifoBuffer* fifoBuffer, uint8* data, uint32 size);
int32 FifoBuffer_dequeue(FifoBuffer* fifoBuffer, uint8* data, uint32 size);

#endif // FIFOBUFFER_H