HALFRED  0.4.0
Data Structures | Macros | Typedefs | Functions
LinkList module

Detailed Description

Introduction.

The LinkList module provides the functionality of a single-link list of items.

Data Structures

struct  LLSTItemDesc
 
struct  LLSTListDesc
 

Macros

#define LLST_DECLARE(name, size, attributes)
 

Typedefs

typedef struct LLSTItemDesc LLSTItemDesc
 
typedef struct LLSTItemDescLLSTItem
 
typedef struct LLSTListDescLLSTList
 

Functions

HALRESULT LLST_Init (LLSTList list, LLSTItem items, size_t size)
 
HALRESULT LLST_Deinit (LLSTList list)
 
HALRESULT LLST_AddItem (LLSTList list, const void *data, LLSTItem *new_item)
 
const void * LLST_UnlinkFirstItem (LLSTList list)
 
const void * LLST_UnlinkLastItem (LLSTList list)
 
const void * LLST_UnlinkItem (LLSTList list, LLSTItem item)
 
LLSTItem LLST_GetFirstItem (LLSTList list)
 
LLSTItem LLST_GetNextItem (LLSTItem item)
 
LLSTItem LLST_GetLastItem (LLSTList list)
 
LLSTItem LLST_GetItemByIndex (LLSTList list, size_t index)
 
LLSTItem LLST_GetItemByData (LLSTList list, const void *data)
 
const void * LLST_GetItemData (LLSTItem item)
 
HALRESULT LLST_SetItemData (LLSTItem item, const void *data)
 

Macro Definition Documentation

#define LLST_DECLARE (   name,
  size,
  attributes 
)
Value:
static LLSTItemDesc name##_items[size]; \
attributes LLSTListDesc name = { size, name##_items , NULL, NULL}
Definition: hal_linklist.h:37
Definition: hal_linklist.h:27

Function Documentation

HALRESULT LLST_Init ( LLSTList  list,
LLSTItem  items,
size_t  size 
)

Initializes link list.

Parameters
listlink list
itemspointer to a pool of items
sizenumber of elements in the pool of items
Return values
HALRESULT_OKif list was initialized successfully
HALRESULT_EMPTY_LINKLISTwhen the provided pool size is zero
HALRESULT_INVALID_LINKLISTwhen the provided pool or list is invalid

References DIAG_DEFAULT_CHANNEL.

HALRESULT LLST_Deinit ( LLSTList  list)

Deinitializes link list.

Parameters
listlink list
Return values
HALRESULT_OKif list was deinitialized successfully
HALRESULT_INVALID_LINKLISTif provided link list is invalid

References DIAG_DEFAULT_CHANNEL.

HALRESULT LLST_AddItem ( LLSTList  list,
const void *  data,
LLSTItem new_item 
)

Adds new item to the list.

Parameters
listlink list
dataitem data
new_itempointer to a variable where the new item will be stored
Return values
HALRESULT_OKif new element was added successfully
HALRESULT_LINKLIST_FULLif the list is full and new element cannot be added
HALRESULT_INVALID_LINKLIST_DATAif the provided data is NULL
HALRESULT_INVALID_LINKLISTif the list is invalid
HALRESULT_EMPTY_LINKLISTif the list pool size is zero

References CORE_EnterCritical, CORE_ExitCritical, and DIAG_DEFAULT_CHANNEL.

const void* LLST_UnlinkFirstItem ( LLSTList  list)

Removes first item from the list.

Parameters
listlink list
Returns
data associated with the removed element

References CORE_EnterCritical, CORE_ExitCritical, and DIAG_DEFAULT_CHANNEL.

const void* LLST_UnlinkLastItem ( LLSTList  list)

Removes last item from the list.

Parameters
listlink list
Returns
data associated with the removed element

References LLST_UnlinkItem().

const void* LLST_UnlinkItem ( LLSTList  list,
LLSTItem  item 
)

Removes a given element from the list.

Parameters
listlink list
item
Returns
data associated with the removed element

References CORE_EnterCritical, CORE_ExitCritical, and DIAG_DEFAULT_CHANNEL.

Referenced by LLST_UnlinkLastItem().

LLSTItem LLST_GetFirstItem ( LLSTList  list)

Retrieves first element on the list.

Parameters
listlink list
Returns
first element on the list or NULL if the list holds no elements

References DIAG_DEFAULT_CHANNEL.

LLSTItem LLST_GetNextItem ( LLSTItem  item)

Retrieves next element on the list, relative to the given one.

Parameters
itemelement on the list
Returns
next element on the list or NULL if the given element is last on the list

References DIAG_DEFAULT_CHANNEL.

LLSTItem LLST_GetLastItem ( LLSTList  list)

Retrieves last element on the list.

Parameters
listlink list
Returns
last element on the list or NULL if the list holds no elements

References DIAG_DEFAULT_CHANNEL.

LLSTItem LLST_GetItemByIndex ( LLSTList  list,
size_t  index 
)

Retrieves item under given index.

Parameters
listlink list
indexindex (0-based)
Returns
item under given index or NULL if there is no element under given index

References DIAG_DEFAULT_CHANNEL.

LLSTItem LLST_GetItemByData ( LLSTList  list,
const void *  data 
)

Retrieves item associated with the given data.

Parameters
listlink list
dataitem data
Returns
item associated with the given data or NULL if there is no such element

References DIAG_DEFAULT_CHANNEL.

const void* LLST_GetItemData ( LLSTItem  item)

Retrieves data associated with a given element.

Parameters
itemelement
Returns
data associated with the given element

References DIAG_DEFAULT_CHANNEL.

HALRESULT LLST_SetItemData ( LLSTItem  item,
const void *  data 
)

Sets data for the given item.

Parameters
itemlink list item
datanew data pointer
Return values
HALRESULT_OKif the item data was set successfully
HALRESULT_INVALID_LINKLIST_ITEMif item was invalid

References DIAG_DEFAULT_CHANNEL.