All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
Data Structures | Functions
include/c/urg_ring_buffer.h File Reference

Ring buffer functions. More...

Go to the source code of this file.

Data Structures

struct  ring_buffer_t
 Control structure of the ring buffer. More...

Functions

void ring_initialize (ring_buffer_t *ring, char *buffer, const int shift_length)
 Initialization.
void ring_clear (ring_buffer_t *ring)
 Clears the ring buffer.
int ring_size (const ring_buffer_t *ring)
 Returns the number of elements on the buffer.
int ring_capacity (const ring_buffer_t *ring)
 Returns the maximum number of elements of the ring buffer.
int ring_write (ring_buffer_t *ring, const char *data, int size)
 Stores data on the ring buffer.
int ring_read (ring_buffer_t *ring, char *buffer, int size)
 Extracts data from the ring buffer.

Detailed Description

Ring buffer functions.

Author:
Satofumi KAMIMURA
Id:
urg_ring_buffer.h,v c5747add6615 2015/05/07 03:18:34 alexandr

Function Documentation

int ring_capacity ( const ring_buffer_t ring)

Returns the maximum number of elements of the ring buffer.

Parameters:
[in]ringPointer to the ring buffer data structure
void ring_clear ( ring_buffer_t ring)

Clears the ring buffer.

Parameters:
[in]ringPointer to the ring buffer data structure
void ring_initialize ( ring_buffer_t ring,
char *  buffer,
const int  shift_length 
)

Initialization.

Parameters:
[in]ringPointer to the ring buffer data structure
[in]bufferActual buffer to use
[in]shift_lengthBuffer size as multiple of 2
int ring_read ( ring_buffer_t ring,
char *  buffer,
int  size 
)

Extracts data from the ring buffer.

Parameters:
[in]ringPointer to the ring buffer data structure
[out]bufferBuffer to hold the extracted data
[in]sizeMaximum size of the buffer
Returns:
The number of elements read from the ring buffer
int ring_size ( const ring_buffer_t ring)

Returns the number of elements on the buffer.

Parameters:
[in]ringPointer to the ring buffer data structure
int ring_write ( ring_buffer_t ring,
const char *  data,
int  size 
)

Stores data on the ring buffer.

Parameters:
[in]ringPointer to the ring buffer data structure
[in]dataData to store
[in]sizeNumber of elements to store
Returns:
The number of elements written to the ring buffer