MediaProcessors
Functions
llist.c File Reference
#include "llist.h"
#include <stdlib.h>
#include <string.h>
#include "check_utils.h"
#include "log.h"
#include "stat_codes.h"
Include dependency graph for llist.c:

Go to the source code of this file.

Functions

int llist_push (llist_t **ref_llist_head, void *data)
 
void * llist_pop (llist_t **ref_llist_head)
 
int llist_len (const llist_t *llist_head)
 
void * llist_get_nth (const llist_t *llist_head, int index)
 
int llist_insert_nth (llist_t **ref_llist_head, int index, void *data)
 

Detailed Description

Author
Rafael Antoniello

Definition in file llist.c.

Function Documentation

void* llist_get_nth ( const llist_t llist_head,
int  index 
)

Get the 'Nth' element of the list (does not delete the element).

Parameters
Pointerto the so-called "head" of the list. Position of the element within the list.
Returns
Pointer to the element if found, NULL otherwise.

Definition at line 113 of file llist.c.

int llist_insert_nth ( llist_t **  ref_llist_head,
int  index,
void *  data 
)

Insert the given element in the 'N-th' position of the list. If the given index position is out of bounds, the element will be appended at the end of the list.

Parameters
ref_llist_headReference to the pointer to the so-called "head" of the list. If the list is empty, the head pointer should be NULL. Position in which the element is to be inserted within the list.
dataPointer to a new data element to be inserted in the list.
Returns
Status code (refer to 'stat_codes_ctx_t' type).
See also
stat_codes_ctx_t

Definition at line 137 of file llist.c.

int llist_len ( const llist_t llist_head)

Return the number of nodes in a list.

Parameters
Pointerto the so-called "head" of the list.
Returns
The number of elements in the list is returned. Note that if a NULL pointer is passed by argument, we assume that the linked list is empty (thus, returning zero).

Definition at line 95 of file llist.c.

void* llist_pop ( llist_t **  ref_llist_head)

Extract the data from the head node of the list, delete the node, and advance the head pointer to point at the next node list.

Parameters
ref_llist_headReference to the pointer to the so-called "head" of the list. The head pointer will be updated to point to the next node of the list.
Returns
Data element popped, or NULL in the case of error due to wrong parameter or empty list.

Definition at line 75 of file llist.c.

int llist_push ( llist_t **  ref_llist_head,
void *  data 
)

Creates a new link node with the given data and pushes it onto the front of the list.

Parameters
ref_llist_headReference to the pointer to the so-called "head" of the list. If the list is empty, the head pointer should be NULL. The head pointer will be updated to the newly created node.
dataPointer to a new data element to be inserted in the list.
Returns
Status code (refer to 'stat_codes_ctx_t' type).
See also
stat_codes_ctx_t

Definition at line 57 of file llist.c.