The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
ring_buffer.h
Go to the documentation of this file.
1#pragma once
2/*
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16 */
17
18/**
19 * $Id: d8f3088307a19dd06a1395d94256ebc8330c2593 $
20 *
21 * @file io/ring_buffer.h
22 * @brief Ring buffers
23 *
24 * @copyright 2016 The FreeRADIUS Server Project
25 * @copyright 2016 Alan DeKok (aland@freeradius.org)
26 */
27RCSIDH(ring_buffer_h, "$Id: d8f3088307a19dd06a1395d94256ebc8330c2593 $")
28
29#include <freeradius-devel/util/talloc.h>
30#include <stdbool.h>
31#include <stdint.h>
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
38
39fr_ring_buffer_t *fr_ring_buffer_create(TALLOC_CTX *ctx, size_t size);
40
42
44
45int fr_ring_buffer_start(fr_ring_buffer_t *dst, uint8_t **p_start, size_t *p_size);
46
48
50
52
54
55void fr_ring_buffer_debug(fr_ring_buffer_t *rb, FILE *fp) CC_HINT(nonnull);
56
57#ifdef __cplusplus
58}
59#endif
#define RCSIDH(h, id)
Definition build.h:484
static fr_ring_buffer_t * rb
unsigned char uint8_t
size_t size
Size of this ring buffer.
Definition ring_buffer.c:37
fr_ring_buffer_t * fr_ring_buffer_create(TALLOC_CTX *ctx, size_t size)
Create a ring buffer.
Definition ring_buffer.c:64
uint8_t * fr_ring_buffer_alloc(fr_ring_buffer_t *rb, size_t size)
Mark data as allocated.
uint8_t * fr_ring_buffer_reserve(fr_ring_buffer_t *rb, size_t size)
Reserve room in the ring buffer.
int fr_ring_buffer_start(fr_ring_buffer_t *dst, uint8_t **p_start, size_t *p_size)
Get a pointer to the data at the start of the ring buffer.
void fr_ring_buffer_debug(fr_ring_buffer_t *rb, FILE *fp)
Print debug information about the ring buffer.
int fr_ring_buffer_free(fr_ring_buffer_t *rb, size_t size)
Mark data as free,.
int fr_ring_buffer_close(fr_ring_buffer_t *rb)
Close a ring buffer so that no further allocations can take place.
size_t fr_ring_buffer_used(fr_ring_buffer_t *rb)
Get the amount of data used in a ring buffer.
size_t fr_ring_buffer_size(fr_ring_buffer_t *rb)
Get the size of the ring buffer.
int nonnull(2, 5))