FreeRDP
ringbuffer.h File Reference
#include <winpr/wtypes.h>
#include <freerdp/api.h>
This graph shows which files directly or indirectly include this file:

Data Structures

struct  RingBuffer
 ring buffer meta data More...
 
struct  DataChunk
 a piece of data in the ring buffer, exactly like a glibc iovec More...
 

Functions

FREERDP_API BOOL ringbuffer_init (RingBuffer *rb, size_t initialSize)
 
FREERDP_API void ringbuffer_destroy (RingBuffer *ringbuffer)
 
FREERDP_API size_t ringbuffer_used (const RingBuffer *ringbuffer)
 
FREERDP_API size_t ringbuffer_capacity (const RingBuffer *ringbuffer)
 
FREERDP_API BOOL ringbuffer_write (RingBuffer *rb, const BYTE *ptr, size_t sz)
 
FREERDP_API BYTEringbuffer_ensure_linear_write (RingBuffer *rb, size_t sz)
 
FREERDP_API BOOL ringbuffer_commit_written_bytes (RingBuffer *rb, size_t sz)
 
FREERDP_API int ringbuffer_peek (const RingBuffer *rb, DataChunk chunks[2], size_t sz)
 
FREERDP_API void ringbuffer_commit_read_bytes (RingBuffer *rb, size_t sz)
 

Function Documentation

◆ ringbuffer_capacity()

FREERDP_API size_t ringbuffer_capacity ( const RingBuffer ringbuffer)

returns the capacity of the ring buffer

Parameters
ringbufferA pointer to the ringbuffer
Returns
the capacity of this ring buffer
Here is the caller graph for this function:

◆ ringbuffer_commit_read_bytes()

FREERDP_API void ringbuffer_commit_read_bytes ( RingBuffer rb,
size_t  sz 
)

move ahead the read head in case some byte were read using ringbuffer_peek() This function is used to commit the bytes that were effectively consumed.

Parameters
rbthe ring buffer
szthe number of bytes to read
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ringbuffer_commit_written_bytes()

FREERDP_API BOOL ringbuffer_commit_written_bytes ( RingBuffer rb,
size_t  sz 
)

move ahead the write head in case some byte were written directly by using a pointer retrieved via ringbuffer_ensure_linear_write(). This function is used to commit the written bytes. The provided size should not exceed the size ensured by ringbuffer_ensure_linear_write()

Parameters
rbthe ring buffer
szthe number of bytes that have been written
Returns
if the operation was successful, FALSE is sz is too big
Here is the caller graph for this function:

◆ ringbuffer_destroy()

FREERDP_API void ringbuffer_destroy ( RingBuffer ringbuffer)

destroys internal data used by this ringbuffer

Parameters
ringbufferA pointer to the ringbuffer
Here is the caller graph for this function:

◆ ringbuffer_ensure_linear_write()

FREERDP_API BYTE* ringbuffer_ensure_linear_write ( RingBuffer rb,
size_t  sz 
)

ensures that we have sz bytes available at the write head, and return a pointer on the write head

Parameters
rbthe ring buffer
szthe size to ensure
Returns
a pointer on the write head, or NULL in case of OOM
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ringbuffer_init()

FREERDP_API BOOL ringbuffer_init ( RingBuffer rb,
size_t  initialSize 
)

initialise a ringbuffer

Parameters
initialSizethe initial capacity of the ringBuffer
Returns
if the initialisation was successful
Here is the caller graph for this function:

◆ ringbuffer_peek()

FREERDP_API int ringbuffer_peek ( const RingBuffer rb,
DataChunk  chunks[2],
size_t  sz 
)

peeks the buffer chunks for sz bytes and returns how many chunks are filled. Note that the sum of the resulting chunks may be smaller than sz.

Parameters
rbthe ringbuffer
chunksan array of data chunks that will contain data / size of chunks
szthe requested size
Returns
the number of chunks used for reading sz bytes
Here is the caller graph for this function:

◆ ringbuffer_used()

FREERDP_API size_t ringbuffer_used ( const RingBuffer ringbuffer)

computes the space used in this ringbuffer

Parameters
ringbufferA pointer to the ringbuffer
Returns
the number of bytes stored in that ringbuffer
Here is the caller graph for this function:

◆ ringbuffer_write()

FREERDP_API BOOL ringbuffer_write ( RingBuffer rb,
const BYTE ptr,
size_t  sz 
)

writes some bytes in the ringbuffer, if the data doesn't fit, the ringbuffer is resized automatically

Parameters
rbthe ringbuffer
ptra pointer on the data to add
szthe size of the data to add
Returns
if the operation was successful, it could fail in case of OOM during realloc()

Write to a ringbuffer

Parameters
rbA pointer to the ringbuffer
ptrA pointer to the data to write
szThe number of bytes to write
Returns
TRUE for success, FALSE for failure
Here is the call graph for this function:
Here is the caller graph for this function: