25 RCSID(
"$Id: 3589c946da23712a0b0d8a251f91b9b6ba610e80 $")
27 #include <freeradius-devel/io/ring_buffer.h>
28 #include <freeradius-devel/util/strerror.h>
29 #include <freeradius-devel/util/debug.h>
75 if (size < 1024) size = 1024;
77 if (size > (1 << 30)) {
163 if (size < rb->data_start) {
267 if (size < rb->data_start) {
313 if (!size_to_free)
return 0;
328 if (size_to_free < block_size) {
338 size_to_free -= block_size;
353 if (!size_to_free)
return 0;
363 if (size_to_free > block_size) {
371 if (size_to_free < block_size) {
487 fprintf(fp,
"Buffer %p, write_offset %zu, data_start %zu, data_end %zu\n",
static fr_ring_buffer_t * rb
size_t data_start
start of used portion of the buffer
size_t reserved
amount of reserved data at write_offset
fr_ring_buffer_t * fr_ring_buffer_create(TALLOC_CTX *ctx, size_t size)
Create a ring buffer.
size_t size
Size of this ring buffer.
uint8_t * fr_ring_buffer_reserve(fr_ring_buffer_t *rb, size_t size)
Reserve room in the ring buffer.
int fr_ring_buffer_free(fr_ring_buffer_t *rb, size_t size_to_free)
Mark data as free,.
size_t write_offset
where writes are done
bool closed
whether allocations are closed
void fr_ring_buffer_debug(fr_ring_buffer_t *rb, FILE *fp)
Print debug information about the ring buffer.
size_t data_end
end of used portion of the buffer
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 fr_ring_buffer_start(fr_ring_buffer_t *rb, uint8_t **p_start, size_t *p_size)
Get a pointer to the data at the start of the ring buffer.
uint8_t * buffer
actual start of the ring buffer
uint8_t * fr_ring_buffer_alloc(fr_ring_buffer_t *rb, size_t size)
Mark data as allocated.
#define fr_strerror_const(_msg)