HALFRED  0.4.0
Data Structures | Macros | Typedefs | Functions
Static list of elements

Detailed Description

Data Structures

struct  SLSTListDesc
 

Macros

#define SLST_GetCount(list)   (((SLSTList)list)->count)
 
#define SLST_Clear(list)   do { ((SLSTList)list)->count = 0; } while (0)
 
#define SLST_Lock(list, timeout)   OSMUTEX_Take((((SLSTList)list)->lock), (timeout))
 
#define SLST_Unlock(list)   OSMUTEX_Give(((SLSTList)list)->lock)
 
#define SLST_GetMemoryFootprint(list)   (sizeof(SLSTListDesc) + (((SLSTList)list)->element_size*((SLSTList)list)->list_size))
 

Typedefs

typedef struct SLSTListDescSLSTList
 

Functions

SLSTList SLST_Create (size_t elem_count, size_t elem_size)
 
void SLST_Destroy (SLSTList list)
 
SLSTList SLST_Init (void *area, size_t area_size, size_t element_size)
 
void * SLST_AddElement (SLSTList list)
 
void * SLST_InsertElement (SLSTList list, const void *element)
 
void * SLST_InsertElementAtPos (SLSTList list, int pos)
 
void SLST_RemoveElement (SLSTList list, void *element)
 
void * SLST_GetElementByField (SLSTList list, const void *field, size_t field_size, uint32_t field_offset)
 
void * SLST_GetNextElement (SLSTList list, void *element)
 
void * SLST_GetFirstElement (SLSTList list)
 

Macro Definition Documentation

#define SLST_GetCount (   list)    (((SLSTList)list)->count)

Returns the number of elements stored in the list

Parameters
listpointer to the list
Returns
number of elements in the list
#define SLST_Clear (   list)    do { ((SLSTList)list)->count = 0; } while (0)

Clears the list

Parameters
listpointer to the list
#define SLST_Lock (   list,
  timeout 
)    OSMUTEX_Take((((SLSTList)list)->lock), (timeout))

Locks access to list for mutually exclusive access

Parameters
listpointer to the list
timeoutmaximum time to wait for access
Returns
0 if access was granted !0 otherwise
#define SLST_Unlock (   list)    OSMUTEX_Give(((SLSTList)list)->lock)

Unlocks access to endpoint list

Parameters
listpointer to the list
#define SLST_GetMemoryFootprint (   list)    (sizeof(SLSTListDesc) + (((SLSTList)list)->element_size*((SLSTList)list)->list_size))

Returns total size of memory used by the list (in bytes)

Function Documentation

SLSTList SLST_Create ( size_t  elem_count,
size_t  elem_size 
)

Creates list

This function uses dynamic memory manager to allocate a buffer space for the list.

Parameters
elem_countcount of elements that list will be able to store
elem_sizesize of a single element that will be stored in the list
Returns
pointer to created list or NULL if list creation failed

References SLSTListDesc::count, SLSTListDesc::element_size, SLSTListDesc::list_size, and OSMUTEX_Create().

void SLST_Destroy ( SLSTList  list)

Destroys list

This function destroys previously created list.

Parameters
listpointer to list that we want to destroy

References OSMUTEX_Destroy().

SLSTList SLST_Init ( void *  area,
size_t  area_size,
size_t  element_size 
)

Initializes list

This function destroys previously created list

Parameters
areapointer to buffer space that will store list and it's descriptor
area_sizesize of "area" space
element_sizesize of a single element that will be stored in the list
Returns
pointer to initialized list or NULL if initialization failed

References SLSTListDesc::count, SLSTListDesc::element_size, and SLSTListDesc::list_size.

void* SLST_AddElement ( SLSTList  list)

Adds single element to the list.

This function reserves space for a next element in the list and returns pointer to that space.

Parameters
listpointer to the list
Returns
pointer to the added element or NULL if element addition failed

References SLSTListDesc::count, SLSTListDesc::element_size, and SLSTListDesc::list_size.

Referenced by SLST_InsertElementAtPos().

void* SLST_InsertElement ( SLSTList  list,
const void *  element 
)

Inserts single element to list at a specified position.

Parameters
listpointer to the list
elementnew element will be inserted before this element
Returns
pointer to added element or NULL if insertion failed.

References SLSTListDesc::element_size, and SLST_InsertElementAtPos().

void* SLST_InsertElementAtPos ( SLSTList  list,
int  pos 
)

Inserts single element to list at a specified position.

Parameters
listpointer to the list
posposition in list, counting from 0
Returns
pointer to added element or NULL if insertion failed.

References SLSTListDesc::count, SLSTListDesc::element_size, SLSTListDesc::list_size, and SLST_AddElement().

Referenced by SLST_InsertElement().

void SLST_RemoveElement ( SLSTList  list,
void *  element 
)

Removes single element from list.

Parameters
listpointer to the list
elementpointer to element to remove

References SLSTListDesc::count, and SLSTListDesc::element_size.

void* SLST_GetElementByField ( SLSTList  list,
const void *  field,
size_t  field_size,
uint32_t  field_offset 
)

Returns pointer to a element that contains specified value in specified field

Parameters
listpointer to the list
fieldpointer to field that have to be compared with piece of list's element
field_sizesize of element pointed by the "Field"
field_offsetoffset in the list's element that have to include compared element
Returns
pointer to found element or NULL when element with specified field could not been found

References SLSTListDesc::count, and SLSTListDesc::element_size.

void* SLST_GetNextElement ( SLSTList  list,
void *  element 
)

Returns pointer to next element in the list

Parameters
listpointer to the list
elementpointer to actually used element
Returns
pointer to next element or NULL when there are no any other elements in the list

References SLSTListDesc::count, and SLSTListDesc::element_size.

void* SLST_GetFirstElement ( SLSTList  list)

Returns pointer to the first element in the list

Parameters
listpointer to the list
Returns
pointer to the first element in the list

References SLSTListDesc::count.