SmartSnippets DA1459x SDK
Data Structures | Typedefs | Functions
sdk_list.h File Reference

Simple helper to manage single-linked list. More...

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  list_elem
 

Typedefs

typedef void(* list_elem_cb_t) (const void *elem, const void *ud)
 
typedef bool(* list_elem_match_t) (const void *elem, const void *ud)
 

Functions

void list_add (void **head, void *elem)
 
void * list_pop_back (void **head)
 
void * list_peek_back (void **head)
 
uint8_t list_size (void *head)
 
void list_append (void **head, void *elem)
 
void * list_find (void *head, list_elem_match_t match, const void *ud)
 
void * list_unlink (void **head, list_elem_match_t match, const void *ud)
 
void list_remove (void **head, list_elem_match_t match, const void *ud)
 
void list_filter (void **head, list_elem_match_t match, const void *ud)
 
void list_foreach (void *head, list_elem_cb_t cb, const void *ud)
 
void list_free (void **head, list_elem_cb_t cb, const void *ud)
 

Detailed Description

Simple helper to manage single-linked list.

Copyright (C) 2015-2019 Renesas Electronics Corporation and/or its affiliates. All rights reserved. Confidential Information.

This software ("Software") is supplied by Renesas Electronics Corporation and/or its affiliates ("Renesas"). Renesas grants you a personal, non-exclusive, non-transferable, revocable, non-sub-licensable right and license to use the Software, solely if used in or together with Renesas products. You may make copies of this Software, provided this copyright notice and disclaimer ("Notice") is included in all such copies. Renesas reserves the right to change or discontinue the Software at any time without notice.

THE SOFTWARE IS PROVIDED "AS IS". RENESAS DISCLAIMS ALL WARRANTIES OF ANY KIND, WHETHER EXPRESS, IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. TO THE MAXIMUM EXTENT PERMITTED UNDER LAW, IN NO EVENT SHALL RENESAS BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE, EVEN IF RENESAS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. USE OF THIS SOFTWARE MAY BE SUBJECT TO TERMS AND CONDITIONS CONTAINED IN AN ADDITIONAL AGREEMENT BETWEEN YOU AND RENESAS. IN CASE OF CONFLICT BETWEEN THE TERMS OF THIS NOTICE AND ANY SUCH ADDITIONAL LICENSE AGREEMENT, THE TERMS OF THE AGREEMENT SHALL TAKE PRECEDENCE. BY CONTINUING TO USE THIS SOFTWARE, YOU AGREE TO THE TERMS OF THIS NOTICE.IF YOU DO NOT AGREE TO THESE TERMS, YOU ARE NOT PERMITTED TO USE THIS SOFTWARE.

Typedef Documentation

◆ list_elem_cb_t

typedef void(* list_elem_cb_t) (const void *elem, const void *ud)

Callback for elements

Parameters
[in]elemevaluated element
[in]uduser data

◆ list_elem_match_t

typedef bool(* list_elem_match_t) (const void *elem, const void *ud)

Callback for matching elements

Parameters
[in]elemevaluated element
[in]uduser data
Returns
true if element is matches, false otherwise

Function Documentation

◆ list_add()

void list_add ( void **  head,
void *  elem 
)

Add element to list

Element is added to the beginning of list.

Parameters
[in,out]headlist head
[in]elemnew element

◆ list_append()

void list_append ( void **  head,
void *  elem 
)

Append element to list

It's recommended to use list_add() whenever possible since it works in constant time.

Parameters
[in,out]headlist head
[in]elemnew element

◆ list_filter()

void list_filter ( void **  head,
list_elem_match_t  match,
const void *  ud 
)

Removes all matched elements from list

Parameters
[in,out]headlist head
[in]matchcallback to match element
[in]uduser data

◆ list_find()

void* list_find ( void *  head,
list_elem_match_t  match,
const void *  ud 
)

Find element in list

Parameters
[in]headlist head
[in]matchcallback to match element
[in]uduser data
Returns
found element or NULL if not found

◆ list_foreach()

void list_foreach ( void *  head,
list_elem_cb_t  cb,
const void *  ud 
)

Iterates over entire list

Parameters
[in]headlist head
[in]cbcallback to be called for each element
[in]uduser data

◆ list_free()

void list_free ( void **  head,
list_elem_cb_t  cb,
const void *  ud 
)

Remove all elements from list

Parameters
[in,out]headlist head
[in]cbcallback to be called for each element before removing it
[in]uduser data

◆ list_peek_back()

void* list_peek_back ( void **  head)

Peek element from the end of the list

Parameters
[in,out]headlist head
Returns
last element in list

◆ list_pop_back()

void* list_pop_back ( void **  head)

Delete element from the end of the list

Parameters
[in,out]headlist head
Returns
last element in list

◆ list_remove()

void list_remove ( void **  head,
list_elem_match_t  match,
const void *  ud 
)

Remove element from list

Parameters
[in,out]headlist head
[in]matchcallback to match element
[in]uduser data

◆ list_size()

uint8_t list_size ( void *  head)

Get number of elements in list

Parameters
[in]headlist head
Returns
number of elements in list

◆ list_unlink()

void* list_unlink ( void **  head,
list_elem_match_t  match,
const void *  ud 
)

Unlink element from list

Parameters
[in,out]headlist head
[in]matchcallback to match element
[in]uduser data
Returns
unlinked element or NULL if not found