42#define CACHED_PAYLOAD_MAX 5
86 data_payload =
ast_calloc(1,
sizeof(*data_payload));
106 buffer_space = buffer->
max - buffer->
count;
118 if (buffer_payload) {
133 if (buffer_payload) {
177 if (buffer->
max == size) {
182 if (buffer->
max > size) {
222 buffer_payload->
pos =
pos;
224 if (!buffer_payload) {
233 buffer_payload->
pos =
pos;
235 if (!buffer_payload) {
242 if (existing_payload->
pos ==
pos) {
243 ast_debug(3,
"Packet with position %zu is already in buffer. Not inserting.\n",
pos);
248 if (existing_payload->
pos >
pos) {
256 if (inserted == -1) {
276 if (buffer_payload->
pos ==
pos) {
277 return buffer_payload->
payload;
306 if (buffer_payload->
pos ==
pos) {
324 if (buffer->
count > 0) {
360 return buffer->
count;
Asterisk main include file. File version handling, generic pbx functions.
#define ast_calloc(num, len)
A wrapper for calloc()
static void data_buffer_free_buffer_payload(struct ast_data_buffer *buffer, struct data_buffer_payload_entry *buffer_payload)
static void ast_data_buffer_cache_adjust(struct ast_data_buffer *buffer)
Helper function that sets the cache to its maximum number of payloads.
void * ast_data_buffer_get(const struct ast_data_buffer *buffer, size_t pos)
Retrieve a data payload from the data buffer.
struct ast_data_buffer * ast_data_buffer_alloc(ast_data_buffer_free_callback free_fn, size_t size)
Allocate a data buffer.
#define CACHED_PAYLOAD_MAX
The number of payloads to increment the cache by.
void * ast_data_buffer_remove_head(struct ast_data_buffer *buffer)
Remove the first payload from the data buffer.
static void free_fn_do_nothing(void *data)
size_t ast_data_buffer_count(const struct ast_data_buffer *buffer)
Return the number of payloads in a data buffer.
void ast_data_buffer_resize(struct ast_data_buffer *buffer, size_t size)
Resize a data buffer.
int ast_data_buffer_put(struct ast_data_buffer *buffer, size_t pos, void *payload)
Place a data payload at a position in the data buffer.
size_t ast_data_buffer_max(const struct ast_data_buffer *buffer)
Return the maximum number of payloads a data buffer can hold.
static struct data_buffer_payload_entry * data_buffer_payload_alloc(void *payload, size_t pos)
Helper function to allocate a data payload.
void * ast_data_buffer_remove(struct ast_data_buffer *buffer, size_t pos)
Remove a data payload from the data buffer.
void ast_data_buffer_free(struct ast_data_buffer *buffer)
Free a data buffer (and all held data payloads)
void(* ast_data_buffer_free_callback)(void *data)
A callback function to free a data payload in a data buffer.
Support for logging to various files, console and syslog Configuration in file logger....
#define ast_debug(level,...)
Log a DEBUG message.
A set of macros to manage forward-linked lists.
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
#define AST_LIST_INSERT_BEFORE_CURRENT(elm, field)
Inserts a list entry before the current entry during a traversal.
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
String manipulation functions.
Data buffer containing fixed number of data payloads.
size_t max
Maximum number of data payloads in the buffer.
struct ast_data_buffer::@340 payloads
A linked list of data payloads.
size_t count
The current number of data payloads in the buffer.
ast_data_buffer_free_callback free_fn
Callback function to free a data payload.
struct ast_data_buffer::@341 cached_payloads
A linked list of unused cached data payloads.
size_t cache_count
The current number of data payloads in the cache.
Payload entry placed inside of the data buffer list.
size_t pos
The provided position for this.
struct data_buffer_payload_entry::@339 list
Linked list information.
void * payload
The payload for this position.