forked from len0rd/rockbox
Simplify mpegplayer a bit and use array-based lists rather than linked lists for stream management. Move a couple useful functions to handle pointer arrays from kernel.c into general.c; mpeglayer now makes use of them.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26101 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
9fde12676b
commit
fcf36dd4f9
15 changed files with 199 additions and 313 deletions
|
@ -102,3 +102,63 @@ uint32_t muldiv_uint32(uint32_t multiplicand,
|
|||
|
||||
return UINT32_MAX; /* Saturate */
|
||||
}
|
||||
|
||||
|
||||
/** Lists **/
|
||||
|
||||
/* Does the list have any members? */
|
||||
bool list_is_empty(void **list)
|
||||
{
|
||||
return *list == NULL;
|
||||
}
|
||||
|
||||
/* Is the item inserted into a particular list? */
|
||||
bool list_is_member(void **list, void *item)
|
||||
{
|
||||
return *rb->find_array_ptr(list, item) != NULL;
|
||||
}
|
||||
|
||||
/* Removes an item from a list - returns true if item was found
|
||||
* and thus removed. */
|
||||
bool list_remove_item(void **list, void *item)
|
||||
{
|
||||
return rb->remove_array_ptr(list, item) != -1;
|
||||
}
|
||||
|
||||
/* Adds a list item, insert last, if not already present. */
|
||||
void list_add_item(void **list, void *item)
|
||||
{
|
||||
void **item_p = rb->find_array_ptr(list, item);
|
||||
if (*item_p == NULL)
|
||||
*item_p = item;
|
||||
}
|
||||
|
||||
/* Clears the entire list. */
|
||||
void list_clear_all(void **list)
|
||||
{
|
||||
while (*list != NULL)
|
||||
*list++ = NULL;
|
||||
}
|
||||
|
||||
/* Enumerate all items in the array, passing each item in turn to the
|
||||
* callback as well as the data value. The current item may be safely
|
||||
* removed. Other changes during enumeration are undefined. The callback
|
||||
* may return 'false' to stop the enumeration early. */
|
||||
void list_enum_items(void **list,
|
||||
list_enum_callback_t callback,
|
||||
intptr_t data)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
void *item = *list;
|
||||
|
||||
if (item == NULL)
|
||||
break;
|
||||
|
||||
if (callback != NULL && !callback(item, data))
|
||||
break;
|
||||
|
||||
if (*list == item)
|
||||
list++; /* Item still there */
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue