All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
cbuff.c File Reference

Implementation of a ring buffer. More...

#include <freeradius-devel/libradius.h>
+ Include dependency graph for cbuff.c:

Go to the source code of this file.

Data Structures

struct  fr_cbuff
 Standard thread safe circular buffer. More...




fr_cbuff_tfr_cbuff_alloc (TALLOC_CTX *ctx, uint32_t size, UNUSED bool lock)
 Initialise a new circular buffer. More...
void fr_cbuff_rp_insert (fr_cbuff_t *cbuff, void *obj)
 Insert a new element into the buffer, and steal it from it's original context. More...
void * fr_cbuff_rp_next (fr_cbuff_t *cbuff, TALLOC_CTX *ctx)
 Remove an item from the buffer, and reparent to ctx. More...

Detailed Description

Implementation of a ring buffer.

Definition in file cbuff.c.

Data Structure Documentation

struct fr_cbuff

Standard thread safe circular buffer.

Definition at line 39 of file cbuff.c.

Data Fields
void ** elem Ring buffer data.
void const * end End of allocated memory.
uint32_t in Write index.
bool lock Perform thread synchronisation.
uint32_t out Read index.
uint32_t size

Macro Definition Documentation

#define PTHREAD_MUTEX_LOCK (   _x)

Definition at line 32 of file cbuff.c.

#define PTHREAD_MUTEX_UNLOCK (   _x)

Definition at line 33 of file cbuff.c.

Function Documentation

fr_cbuff_t* fr_cbuff_alloc ( TALLOC_CTX *  ctx,
uint32_t  size,
UNUSED bool  lock 

Initialise a new circular buffer.

ctxto allocate the buffer in.
sizeof buffer to allocate.
lockIf true, insert and next operations will lock the buffer.
  • New cbuff.
  • NULL on error.

Definition at line 66 of file cbuff.c.

void fr_cbuff_rp_insert ( fr_cbuff_t cbuff,
void *  obj 

Insert a new element into the buffer, and steal it from it's original context.

cbuff will steal obj and insert it into it's own context.

cbuffto insert element into
objto insert, must of been allocated with talloc

Definition at line 108 of file cbuff.c.

void* fr_cbuff_rp_next ( fr_cbuff_t cbuff,
TALLOC_CTX *  ctx 

Remove an item from the buffer, and reparent to ctx.

cbuffto remove element from
ctxto hang obj off.
  • NULL if no elements in the buffer.
  • An element from the buffer reparented to ctx.

Definition at line 136 of file cbuff.c.