FreeRDP
|
#include <freerdp/config.h>
#include <freerdp/utils/ringbuffer.h>
#include <stdlib.h>
#include <string.h>
#include <winpr/assert.h>
#include <winpr/crt.h>
#include <freerdp/log.h>
Macros | |
#define | TAG FREERDP_TAG("utils.ringbuffer") |
#define | DEBUG_RINGBUFFER(...) |
Functions | |
BOOL | ringbuffer_init (RingBuffer *rb, size_t initialSize) |
size_t | ringbuffer_used (const RingBuffer *rb) |
size_t | ringbuffer_capacity (const RingBuffer *rb) |
void | ringbuffer_destroy (RingBuffer *rb) |
static BOOL | ringbuffer_realloc (RingBuffer *rb, size_t targetSize) |
BOOL | ringbuffer_write (RingBuffer *rb, const BYTE *ptr, size_t sz) |
BYTE * | ringbuffer_ensure_linear_write (RingBuffer *rb, size_t sz) |
BOOL | ringbuffer_commit_written_bytes (RingBuffer *rb, size_t sz) |
int | ringbuffer_peek (const RingBuffer *rb, DataChunk chunks[2], size_t sz) |
void | ringbuffer_commit_read_bytes (RingBuffer *rb, size_t sz) |
#define DEBUG_RINGBUFFER | ( | ... | ) |
#define TAG FREERDP_TAG("utils.ringbuffer") |
FreeRDP: A Remote Desktop Protocol Implementation
Copyright 2014 Thincast Technologies GmbH Copyright 2014 Hardening conta ct@h arden ing- consu ltin g.com
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
size_t ringbuffer_capacity | ( | const RingBuffer * | ringbuffer | ) |
returns the capacity of the ring buffer
ringbuffer | A pointer to the ringbuffer |
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.
rb | the ring buffer |
sz | the number of bytes to read |
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()
rb | the ring buffer |
sz | the number of bytes that have been written |
void ringbuffer_destroy | ( | RingBuffer * | ringbuffer | ) |
destroys internal data used by this ringbuffer
ringbuffer | A pointer to the ringbuffer |
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
rb | the ring buffer |
sz | the size to ensure |
BOOL ringbuffer_init | ( | RingBuffer * | rb, |
size_t | initialSize | ||
) |
initialise a ringbuffer
initialSize | the initial capacity of the ringBuffer |
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.
rb | the ringbuffer |
chunks | an array of data chunks that will contain data / size of chunks |
sz | the requested size |
|
static |
size_t ringbuffer_used | ( | const RingBuffer * | ringbuffer | ) |
computes the space used in this ringbuffer
ringbuffer | A pointer to the ringbuffer |
BOOL ringbuffer_write | ( | RingBuffer * | rb, |
const BYTE * | ptr, | ||
size_t | sz | ||
) |
Write to a ringbuffer
rb | A pointer to the ringbuffer |
ptr | A pointer to the data to write |
sz | The number of bytes to write |