2017-01-14 23:46:31 +08:00
|
|
|
/*
|
|
|
|
* Copyright © 2016-2017 The TokTok team.
|
|
|
|
* Copyright © 2013 Tox project.
|
|
|
|
* Copyright © 2013 plutooo
|
|
|
|
*
|
|
|
|
* This file is part of Tox, the free peer to peer instant messenger.
|
|
|
|
* This file is donated to the Tox Project.
|
|
|
|
*
|
|
|
|
* Tox is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Tox is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Tox. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2016-09-22 22:20:33 +08:00
|
|
|
#ifndef RING_BUFFER_H
|
|
|
|
#define RING_BUFFER_H
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2018-07-04 02:14:36 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2016-09-22 22:20:33 +08:00
|
|
|
/* Ring buffer */
|
|
|
|
typedef struct RingBuffer RingBuffer;
|
|
|
|
bool rb_full(const RingBuffer *b);
|
|
|
|
bool rb_empty(const RingBuffer *b);
|
|
|
|
void *rb_write(RingBuffer *b, void *p);
|
|
|
|
bool rb_read(RingBuffer *b, void **p);
|
|
|
|
RingBuffer *rb_new(int size);
|
|
|
|
void rb_kill(RingBuffer *b);
|
|
|
|
uint16_t rb_size(const RingBuffer *b);
|
|
|
|
uint16_t rb_data(const RingBuffer *b, void **dest);
|
|
|
|
|
2018-07-04 02:14:36 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-09-22 22:20:33 +08:00
|
|
|
#endif /* RING_BUFFER_H */
|