The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Typedefs | Functions
fring.h File Reference

Simple ring buffer with fixed element sizes. More...

#include <freeradius-devel/build.h>
#include <freeradius-devel/missing.h>
#include <freeradius-devel/util/talloc.h>
#include <stdbool.h>
#include <stdint.h>
+ Include dependency graph for fring.h:

Go to the source code of this file.

Typedefs

typedef struct fr_fring_buffer fr_fring_t
 

Functions

fr_fring_tfr_fring_alloc (TALLOC_CTX *ctx, uint32_t size, bool lock)
 Initialise a ring buffer with fixed element size. More...
 
int fr_fring_insert (fr_fring_t *fring, void *obj)
 Insert a new item into the circular buffer if the buffer is not full. More...
 
void * fr_fring_next (fr_fring_t *fring)
 Remove an item from the buffer. More...
 
int fr_fring_overwrite (fr_fring_t *fring, void *obj)
 Insert a new item into the circular buffer, freeing the tail if we hit it. More...
 

Detailed Description

Simple ring buffer with fixed element sizes.

Definition in file fring.h.

Typedef Documentation

◆ fr_fring_t

typedef struct fr_fring_buffer fr_fring_t

Definition at line 1 of file fring.h.

Function Documentation

◆ fr_fring_alloc()

fr_fring_t* fr_fring_alloc ( TALLOC_CTX *  ctx,
uint32_t  size,
bool  lock 
)

Initialise a ring buffer with fixed element size.

Parameters
[in]ctxto allocate the buffer in.
[in]sizeof buffer to allocate.
[in]lockIf true, insert and next operations will lock the buffer.
Returns
  • New fring.
  • NULL on error.

Definition at line 78 of file fring.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_fring_insert()

int fr_fring_insert ( fr_fring_t fring,
void *  in 
)

Insert a new item into the circular buffer if the buffer is not full.

Parameters
[in]fringto insert item into.
[in]initem to insert.
Returns
  • 0 if we inserted the item.
  • -1 if there's no more space in the buffer to insert items

Definition at line 149 of file fring.c.

+ Here is the call graph for this function:

◆ fr_fring_next()

void* fr_fring_next ( fr_fring_t fring)

Remove an item from the buffer.

Parameters
[in]fringto drain data from.
Returns
  • NULL if no dataents in the buffer.
  • An dataent from the buffer reparented to ctx.

Definition at line 177 of file fring.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_fring_overwrite()

int fr_fring_overwrite ( fr_fring_t fring,
void *  in 
)

Insert a new item into the circular buffer, freeing the tail if we hit it.

Parameters
[in]fringto insert item into
[in]initem to insert (must have been allocated with talloc).
Returns
  • 0 if we inserted the item without freeing existing items.
  • 1 if we inserted the item, but needed to free an existing item.

Definition at line 120 of file fring.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function: