27 lines
543 B
C
27 lines
543 B
C
#ifndef SQUEUE_H
|
|
#define SQUEUE_H
|
|
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
#include <stdbool.h>
|
|
#include <string.h>
|
|
|
|
// FIFO.
|
|
|
|
typedef struct {
|
|
void *buffer;
|
|
uint16_t head;
|
|
uint16_t tail;
|
|
uint16_t count;
|
|
uint16_t capacity;
|
|
size_t element_size;
|
|
} SQueue;
|
|
|
|
bool squeue_init(SQueue *q, uint16_t capacity, size_t element_size);
|
|
void squeue_free(SQueue *q);
|
|
|
|
bool squeue_push(SQueue *q, const void *elem);
|
|
bool squeue_pop(SQueue *q, void *out);
|
|
bool squeue_peek(const SQueue *q, void *out);
|
|
|
|
#endif |