The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
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  */
27 RCSIDH(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
34 extern "C" {
35 #endif
36 
37 typedef struct fr_ring_buffer_s fr_ring_buffer_t;
38 
39 fr_ring_buffer_t *fr_ring_buffer_create(TALLOC_CTX *ctx, size_t size);
40 
42 
44 
45 int fr_ring_buffer_start(fr_ring_buffer_t *dst, uint8_t **p_start, size_t *p_size);
46 
47 int fr_ring_buffer_free(fr_ring_buffer_t *rb, size_t size) CC_HINT(nonnull);
48 
50 
52 
54 
55 void 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:445
static fr_ring_buffer_t * rb
Definition: control_test.c:51
unsigned char uint8_t
Definition: merged_model.c:30
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_reserve(fr_ring_buffer_t *rb, size_t size)
Reserve room in the ring buffer.
Definition: ring_buffer.c:119
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.
Definition: ring_buffer.c:464
void fr_ring_buffer_debug(fr_ring_buffer_t *rb, FILE *fp)
Print debug information about the ring buffer.
Definition: ring_buffer.c:485
int fr_ring_buffer_free(fr_ring_buffer_t *rb, size_t size)
Mark data as free,.
Definition: ring_buffer.c:304
int fr_ring_buffer_close(fr_ring_buffer_t *rb)
Close a ring buffer so that no further allocations can take place.
Definition: ring_buffer.c:407
size_t fr_ring_buffer_used(fr_ring_buffer_t *rb)
Get the amount of data used in a ring buffer.
Definition: ring_buffer.c:437
size_t fr_ring_buffer_size(fr_ring_buffer_t *rb)
Get the size of the ring buffer.
Definition: ring_buffer.c:423
uint8_t * fr_ring_buffer_alloc(fr_ring_buffer_t *rb, size_t size)
Mark data as allocated.
Definition: ring_buffer.c:196
int nonnull(2, 5))