Docs

You are here:
Static list of elements

Classes

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)
 

Detailed Description

Macro Definition Documentation

#define SLST_Clear (   list)    do { ((SLSTList)list)->count = 0; } while (0)

Clears the list

Parameters
listpointer to the list
#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_GetMemoryFootprint (   list)    (sizeof(SLSTListDesc) + (((SLSTList)list)->element_size*((SLSTList)list)->list_size))

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

#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

Function Documentation

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
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
void SLST_Destroy ( SLSTList  list)

Destroys list

This function destroys previously created list.

Parameters
listpointer to list that we want to destroy
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
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
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
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
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.
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.
void SLST_RemoveElement ( SLSTList  list,
void *  element 
)

Removes single element from list.

Parameters
listpointer to the list
elementpointer to element to remove
Go to Top