FreeRTOS: BLE
BLE
Return to main page ↑
iot_ble_linear_containers.h
Go to the documentation of this file.
1 /*
2  * FreeRTOS Common V1.2.0
3  * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * http://aws.amazon.com/freertos
23  * http://www.FreeRTOS.org
24  */
25 
31 #ifndef IOT_LINEAR_CONTAINERS_H_
32 #define IOT_LINEAR_CONTAINERS_H_
33 
34 /* The config header is always included first. */
35 #include "iot_config.h"
36 
37 /* Standard includes. */
38 #include <stdbool.h>
39 #include <stddef.h>
40 #include <stdint.h>
41 
55 typedef struct IotLink
56 {
57  struct IotLink * pPrevious;
58  struct IotLink * pNext;
59 } IotLink_t;
60 
66 
72 
90 /* @[define_linear_containers_initializers] */
91 #define IOT_LINK_INITIALIZER { 0 }
92 #define IOT_LIST_DOUBLE_INITIALIZER IOT_LINK_INITIALIZER
93 #define IOT_DEQUEUE_INITIALIZER IOT_LINK_INITIALIZER
94 /* @[define_linear_containers_initializers] */
95 
105 #if IOT_CONTAINERS_ENABLE_ASSERTS == 1
106  #ifndef IotContainers_Assert
107  #include <assert.h>
108  #define IotContainers_Assert( expression ) assert( expression )
109  #endif
110 #else
111  #define IotContainers_Assert( expression )
112 #endif
113 
121 #define IotLink_Container( type, pLink, linkName ) \
122  ( ( type * ) ( void * ) ( ( ( uint8_t * ) ( pLink ) ) - offsetof( type, linkName ) ) )
123 
132 #define IotContainers_ForEach( pStart, pLink ) \
133  for( ( pLink ) = ( pStart )->pNext; \
134  ( pLink ) != ( pStart ); \
135  ( pLink ) = ( pLink )->pNext )
136 
302 /* @[declare_linear_containers_link_islinked] */
303 static inline bool IotLink_IsLinked( const IotLink_t * const pLink )
304 /* @[declare_linear_containers_link_islinked] */
305 {
306  bool isLinked = false;
307 
308  if( pLink != NULL )
309  {
310  isLinked = ( pLink->pNext != NULL ) && ( pLink->pPrevious != NULL );
311  }
312 
313  return isLinked;
314 }
315 
329 /* @[declare_linear_containers_list_double_create] */
330 static inline void IotListDouble_Create( IotListDouble_t * const pList )
331 /* @[declare_linear_containers_list_double_create] */
332 {
333  /* This function must not be called with a NULL parameter. */
334  IotContainers_Assert( pList != NULL );
335 
336  /* An empty list is a link pointing to itself. */
337  pList->pPrevious = pList;
338  pList->pNext = pList;
339 }
340 
348 /* @[declare_linear_containers_list_double_count] */
349 static inline size_t IotListDouble_Count( const IotListDouble_t * const pList )
350 /* @[declare_linear_containers_list_double_count] */
351 {
352  size_t count = 0;
353 
354  if( pList != NULL )
355  {
356  /* Get the list head. */
357  const IotLink_t * pCurrent = pList->pNext;
358 
359  /* Iterate through the list to count the elements. */
360  while( pCurrent != pList )
361  {
362  count++;
363  pCurrent = pCurrent->pNext;
364  }
365  }
366 
367  return count;
368 }
369 
377 /* @[declare_linear_containers_list_double_isempty] */
378 static inline bool IotListDouble_IsEmpty( const IotListDouble_t * const pList )
379 /* @[declare_linear_containers_list_double_isempty] */
380 {
381  /* An empty list is NULL link, or a link pointing to itself. */
382  return( ( pList == NULL ) || ( pList->pNext == pList ) );
383 }
384 
395 /* @[declare_linear_containers_list_double_peekhead] */
396 static inline IotLink_t * IotListDouble_PeekHead( const IotListDouble_t * const pList )
397 /* @[declare_linear_containers_list_double_peekhead] */
398 {
399  IotLink_t * pHead = NULL;
400 
401  if( pList != NULL )
402  {
403  if( IotListDouble_IsEmpty( pList ) == false )
404  {
405  pHead = pList->pNext;
406  }
407  }
408 
409  return pHead;
410 }
411 
422 /* @[declare_linear_containers_list_double_peektail] */
423 static inline IotLink_t * IotListDouble_PeekTail( const IotListDouble_t * const pList )
424 /* @[declare_linear_containers_list_double_peektail] */
425 {
426  IotLink_t * pTail = NULL;
427 
428  if( pList != NULL )
429  {
430  if( IotListDouble_IsEmpty( pList ) == false )
431  {
432  pTail = pList->pPrevious;
433  }
434  }
435 
436  return pTail;
437 }
438 
445 /* @[declare_linear_containers_list_double_inserthead] */
446 static inline void IotListDouble_InsertHead( IotListDouble_t * const pList,
447  IotLink_t * const pLink )
448 /* @[declare_linear_containers_list_double_inserthead] */
449 {
450  /* This function must not be called with NULL parameters. */
451  IotContainers_Assert( pList != NULL );
452  IotContainers_Assert( pLink != NULL );
453 
454  /* Save current list head. */
455  IotLink_t * pHead = pList->pNext;
456 
457  /* Place new element before list head. */
458  pLink->pNext = pHead;
459  pLink->pPrevious = pList;
460 
461  /* Assign new list head. */
462  pHead->pPrevious = pLink;
463  pList->pNext = pLink;
464 }
465 
472 /* @[declare_linear_containers_list_double_inserttail] */
473 static inline void IotListDouble_InsertTail( IotListDouble_t * const pList,
474  IotLink_t * const pLink )
475 /* @[declare_linear_containers_list_double_inserttail] */
476 {
477  /* This function must not be called with NULL parameters. */
478  IotContainers_Assert( pList != NULL );
479  IotContainers_Assert( pLink != NULL );
480 
481  /* Save current list tail. */
482  IotLink_t * pTail = pList->pPrevious;
483 
484  pLink->pNext = pList;
485  pLink->pPrevious = pTail;
486 
487  pList->pPrevious = pLink;
488  pTail->pNext = pLink;
489 }
490 
497 /* @[declare_linear_containers_list_double_insertbefore] */
498 static inline void IotListDouble_InsertBefore( IotLink_t * const pElement,
499  IotLink_t * const pLink )
500 /* @[declare_linear_containers_list_double_insertbefore] */
501 {
502  IotListDouble_InsertTail( pElement, pLink );
503 }
504 
511 /* @[declare_linear_containers_list_double_insertafter] */
512 static inline void IotListDouble_InsertAfter( IotLink_t * const pElement,
513  IotLink_t * const pLink )
514 /* @[declare_linear_containers_list_double_insertafter] */
515 {
516  IotListDouble_InsertHead( pElement, pLink );
517 }
518 
534 /* @[declare_linear_containers_list_double_insertsorted] */
535 static inline void IotListDouble_InsertSorted( IotListDouble_t * const pList,
536  IotLink_t * const pLink,
537  int32_t ( * compare )( const IotLink_t * const, const IotLink_t * const ) )
538 /* @[declare_linear_containers_list_double_insertsorted] */
539 {
540  /* This function must not be called with NULL parameters. */
541  IotContainers_Assert( pList != NULL );
542  IotContainers_Assert( pLink != NULL );
543  IotContainers_Assert( compare != NULL );
544 
545  /* Insert at head for empty list. */
546  if( IotListDouble_IsEmpty( pList ) == true )
547  {
548  IotListDouble_InsertHead( pList, pLink );
549  }
550  else
551  {
552  bool inserted = false;
553  IotLink_t * pCurrent = pList->pNext;
554 
555  /* Iterate through the list to find the correct position. */
556  while( pCurrent != pList )
557  {
558  /* Comparing for '<' preserves the order of insertion. */
559  if( compare( pLink, pCurrent ) < 0 )
560  {
561  IotListDouble_InsertBefore( pCurrent, pLink );
562  inserted = true;
563 
564  break;
565  }
566 
567  pCurrent = pCurrent->pNext;
568  }
569 
570  /* New element is greater than all elements in list. Insert at tail. */
571  if( inserted == false )
572  {
573  IotListDouble_InsertTail( pList, pLink );
574  }
575  }
576 }
577 
583 /* @[declare_linear_containers_list_double_remove] */
584 static inline void IotListDouble_Remove( IotLink_t * const pLink )
585 /* @[declare_linear_containers_list_double_remove] */
586 {
587  /* This function must not be called with a NULL parameter. */
588  IotContainers_Assert( pLink != NULL );
589 
590  /* This function must be called on a linked element. */
591  IotContainers_Assert( IotLink_IsLinked( pLink ) == true );
592 
593  pLink->pPrevious->pNext = pLink->pNext;
594  pLink->pNext->pPrevious = pLink->pPrevious;
595  pLink->pPrevious = NULL;
596  pLink->pNext = NULL;
597 }
598 
608 /* @[declare_linear_containers_list_double_removehead] */
609 static inline IotLink_t * IotListDouble_RemoveHead( IotListDouble_t * const pList )
610 /* @[declare_linear_containers_list_double_removehead] */
611 {
612  IotLink_t * pHead = NULL;
613 
614  if( IotListDouble_IsEmpty( pList ) == false )
615  {
616  pHead = pList->pNext;
617  IotListDouble_Remove( pHead );
618  }
619 
620  return pHead;
621 }
622 
632 /* @[declare_linear_containers_list_double_removetail] */
633 static inline IotLink_t * IotListDouble_RemoveTail( IotListDouble_t * const pList )
634 /* @[declare_linear_containers_list_double_removetail] */
635 {
636  IotLink_t * pTail = NULL;
637 
638  if( IotListDouble_IsEmpty( pList ) == false )
639  {
640  pTail = pList->pPrevious;
641  IotListDouble_Remove( pTail );
642  }
643 
644  return pTail;
645 }
646 
658 /* @[declare_linear_containers_list_double_removeall] */
659 static inline void IotListDouble_RemoveAll( IotListDouble_t * const pList,
660  void ( * freeElement )( void * ),
661  size_t linkOffset )
662 /* @[declare_linear_containers_list_double_removeall] */
663 {
664  /* This function must not be called with a NULL pList parameter. */
665  IotContainers_Assert( pList != NULL );
666 
667  /* Get the list head. */
668  IotLink_t * pCurrent = pList->pNext;
669 
670  /* Iterate through the list and remove all elements. */
671  while( pCurrent != pList )
672  {
673  /* Save a pointer to the next list element. */
674  IotLink_t * pNext = pCurrent->pNext;
675 
676  /* Remove and free the current list element. */
677  IotListDouble_Remove( pCurrent );
678 
679  if( freeElement != NULL )
680  {
681  freeElement( ( ( uint8_t * ) pCurrent ) - linkOffset );
682  }
683 
684  /* Move the iterating pointer to the next list element. */
685  pCurrent = pNext;
686  }
687 }
688 
709 /* @[declare_linear_containers_list_double_findfirstmatch] */
710 static inline IotLink_t * IotListDouble_FindFirstMatch( const IotListDouble_t * const pList,
711  const IotLink_t * const pStartPoint,
712  bool ( * isMatch )( const IotLink_t * const, void * ),
713  void * pMatch )
714 /* @[declare_linear_containers_list_double_findfirstmatch] */
715 {
716  /* The const must be cast away to match this function's return value. Nevertheless,
717  * this function will respect the const-ness of pStartPoint. */
718  IotLink_t * pCurrent = ( IotLink_t * ) pStartPoint;
719 
720  /* This function must not be called with a NULL pList parameter. */
721  IotContainers_Assert( pList != NULL );
722 
723  /* Search starting from list head if no start point is given. */
724  if( pStartPoint == NULL )
725  {
726  pCurrent = pList->pNext;
727  }
728 
729  /* Iterate through the list to search for matches. */
730  while( pCurrent != pList )
731  {
732  /* Call isMatch if provided. Otherwise, compare pointers. */
733  if( isMatch != NULL )
734  {
735  if( isMatch( pCurrent, pMatch ) == true )
736  {
737  return pCurrent;
738  }
739  }
740  else
741  {
742  if( pCurrent == pMatch )
743  {
744  return pCurrent;
745  }
746  }
747 
748  pCurrent = pCurrent->pNext;
749  }
750 
751  /* No match found, return NULL. */
752  return NULL;
753 }
754 
775 /* @[declare_linear_containers_list_double_removefirstmatch] */
777  const IotLink_t * const pStartPoint,
778  bool ( * isMatch )( const IotLink_t *, void * ),
779  void * pMatch )
780 /* @[declare_linear_containers_list_double_removefirstmatch] */
781 {
782  IotLink_t * pMatchedElement = IotListDouble_FindFirstMatch( pList,
783  pStartPoint,
784  isMatch,
785  pMatch );
786 
787  if( pMatchedElement != NULL )
788  {
789  IotListDouble_Remove( pMatchedElement );
790  }
791 
792  return pMatchedElement;
793 }
794 
811 /* @[declare_linear_containers_list_double_removeallmatches] */
812 static inline void IotListDouble_RemoveAllMatches( IotListDouble_t * const pList,
813  bool ( * isMatch )( const IotLink_t *, void * ),
814  void * pMatch,
815  void ( * freeElement )( void * ),
816  size_t linkOffset )
817 /* @[declare_linear_containers_list_double_removeallmatches] */
818 {
819  IotLink_t * pMatchedElement = NULL, * pNextElement = NULL;
820 
821  /* Search the list for all matching elements. */
822  do
823  {
824  pMatchedElement = IotListDouble_FindFirstMatch( pList,
825  pMatchedElement,
826  isMatch,
827  pMatch );
828 
829  if( pMatchedElement != NULL )
830  {
831  /* Save pointer to next element. */
832  pNextElement = pMatchedElement->pNext;
833 
834  /* Match found; remove and free. */
835  IotListDouble_Remove( pMatchedElement );
836 
837  if( freeElement != NULL )
838  {
839  freeElement( ( ( uint8_t * ) pMatchedElement ) - linkOffset );
840  }
841 
842  /* Continue search from next element. */
843  pMatchedElement = pNextElement;
844  }
845  } while( pMatchedElement != NULL );
846 }
847 
859 /* @[declare_linear_containers_queue_create] */
860 static inline void IotDeQueue_Create( IotDeQueue_t * const pQueue )
861 /* @[declare_linear_containers_queue_create] */
862 {
863  IotListDouble_Create( pQueue );
864 }
865 
873 /* @[declare_linear_containers_queue_count] */
874 static inline size_t IotDeQueue_Count( const IotDeQueue_t * const pQueue )
875 /* @[declare_linear_containers_queue_count] */
876 {
877  return IotListDouble_Count( pQueue );
878 }
879 
888 /* @[declare_linear_containers_queue_isempty] */
889 static inline bool IotDeQueue_IsEmpty( const IotDeQueue_t * const pQueue )
890 /* @[declare_linear_containers_queue_isempty] */
891 {
892  return IotListDouble_IsEmpty( pQueue );
893 }
894 
905 /* @[declare_linear_containers_queue_peekhead] */
906 static inline IotLink_t * IotDeQueue_PeekHead( const IotDeQueue_t * const pQueue )
907 /* @[declare_linear_containers_queue_peekhead] */
908 {
909  return IotListDouble_PeekHead( pQueue );
910 }
911 
922 /* @[declare_linear_containers_queue_peektail] */
923 static inline IotLink_t * IotDeQueue_PeekTail( const IotDeQueue_t * const pQueue )
924 /* @[declare_linear_containers_queue_peektail] */
925 {
926  return IotListDouble_PeekTail( pQueue );
927 }
928 
935 /* @[declare_linear_containers_queue_enqueuehead] */
936 static inline void IotDeQueue_EnqueueHead( IotDeQueue_t * const pQueue,
937  IotLink_t * const pLink )
938 /* @[declare_linear_containers_queue_enqueuehead] */
939 {
940  IotListDouble_InsertHead( pQueue, pLink );
941 }
942 
952 /* @[declare_linear_containers_queue_dequeuehead] */
953 static inline IotLink_t * IotDeQueue_DequeueHead( IotDeQueue_t * const pQueue )
954 /* @[declare_linear_containers_queue_dequeuehead] */
955 {
956  return IotListDouble_RemoveHead( pQueue );
957 }
958 
965 /* @[declare_linear_containers_queue_enqueuetail] */
966 static inline void IotDeQueue_EnqueueTail( IotDeQueue_t * const pQueue,
967  IotLink_t * const pLink )
968 /* @[declare_linear_containers_queue_enqueuetail] */
969 {
970  IotListDouble_InsertTail( pQueue, pLink );
971 }
972 
982 /* @[declare_linear_containers_queue_dequeuetail] */
983 static inline IotLink_t * IotDeQueue_DequeueTail( IotDeQueue_t * const pQueue )
984 /* @[declare_linear_containers_queue_dequeuetail] */
985 {
986  return IotListDouble_RemoveTail( pQueue );
987 }
988 
994 /* @[declare_linear_containers_queue_remove] */
995 static inline void IotDeQueue_Remove( IotLink_t * const pLink )
996 /* @[declare_linear_containers_queue_remove] */
997 {
998  IotListDouble_Remove( pLink );
999 }
1000 
1012 /* @[declare_linear_containers_queue_removeall] */
1013 static inline void IotDeQueue_RemoveAll( IotDeQueue_t * const pQueue,
1014  void ( * freeElement )( void * ),
1015  size_t linkOffset )
1016 /* @[declare_linear_containers_queue_removeall] */
1017 {
1018  IotListDouble_RemoveAll( pQueue, freeElement, linkOffset );
1019 }
1020 
1037 /* @[declare_linear_containers_queue_removeallmatches] */
1038 static inline void IotDeQueue_RemoveAllMatches( IotDeQueue_t * const pQueue,
1039  bool ( * isMatch )( const IotLink_t *, void * ),
1040  void * pMatch,
1041  void ( * freeElement )( void * ),
1042  size_t linkOffset )
1043 /* @[declare_linear_containers_queue_removeallmatches] */
1044 {
1045  IotListDouble_RemoveAllMatches( pQueue, isMatch, pMatch, freeElement, linkOffset );
1046 }
1047 
1048 #endif /* IOT_LINEAR_CONTAINERS_H_ */
static void IotListDouble_Create(IotListDouble_t *const pList)
Create a new doubly-linked list.
Definition: iot_ble_linear_containers.h:330
static IotLink_t * IotListDouble_FindFirstMatch(const IotListDouble_t *const pList, const IotLink_t *const pStartPoint, bool(*isMatch)(const IotLink_t *const, void *), void *pMatch)
Search a doubly-linked list for the first matching element.
Definition: iot_ble_linear_containers.h:710
static IotLink_t * IotListDouble_PeekTail(const IotListDouble_t *const pList)
Return an IotLink_t representing the last element in a doubly-linked list without removing it...
Definition: iot_ble_linear_containers.h:423
static void IotDeQueue_EnqueueHead(IotDeQueue_t *const pQueue, IotLink_t *const pLink)
Add an element at the head of the queue.
Definition: iot_ble_linear_containers.h:936
static void IotDeQueue_RemoveAll(IotDeQueue_t *const pQueue, void(*freeElement)(void *), size_t linkOffset)
Remove all elements in a queue.
Definition: iot_ble_linear_containers.h:1013
static void IotDeQueue_Create(IotDeQueue_t *const pQueue)
Create a new queue.
Definition: iot_ble_linear_containers.h:860
static bool IotListDouble_IsEmpty(const IotListDouble_t *const pList)
Check if a doubly-linked list is empty.
Definition: iot_ble_linear_containers.h:378
static void IotListDouble_InsertSorted(IotListDouble_t *const pList, IotLink_t *const pLink, int32_t(*compare)(const IotLink_t *const, const IotLink_t *const))
Insert an element in a sorted doubly-linked list.
Definition: iot_ble_linear_containers.h:535
static IotLink_t * IotDeQueue_PeekHead(const IotDeQueue_t *const pQueue)
Return an IotLink_t representing the element at the front of the queue without removing it...
Definition: iot_ble_linear_containers.h:906
static IotLink_t * IotListDouble_RemoveFirstMatch(IotListDouble_t *const pList, const IotLink_t *const pStartPoint, bool(*isMatch)(const IotLink_t *, void *), void *pMatch)
Search a doubly-linked list for the first matching element and remove it.
Definition: iot_ble_linear_containers.h:776
IotLink_t IotDeQueue_t
Represents a queue.
Definition: iot_ble_linear_containers.h:71
static size_t IotListDouble_Count(const IotListDouble_t *const pList)
Return the number of elements contained in an IotListDouble_t.
Definition: iot_ble_linear_containers.h:349
static void IotListDouble_InsertHead(IotListDouble_t *const pList, IotLink_t *const pLink)
Insert an element at the head of a doubly-linked list.
Definition: iot_ble_linear_containers.h:446
static IotLink_t * IotDeQueue_PeekTail(const IotDeQueue_t *const pQueue)
Return an IotLink_t representing the element at the back of the queue without removing it...
Definition: iot_ble_linear_containers.h:923
static void IotListDouble_Remove(IotLink_t *const pLink)
Remove a single element from a doubly-linked list.
Definition: iot_ble_linear_containers.h:584
#define IotContainers_Assert(expression)
Assertion macro for the linear containers library.
Definition: iot_ble_linear_containers.h:111
static IotLink_t * IotListDouble_RemoveTail(IotListDouble_t *const pList)
Remove the element at the tail of a doubly-linked list.
Definition: iot_ble_linear_containers.h:633
static void IotListDouble_InsertTail(IotListDouble_t *const pList, IotLink_t *const pLink)
Insert an element at the tail of a doubly-linked list.
Definition: iot_ble_linear_containers.h:473
static IotLink_t * IotDeQueue_DequeueHead(IotDeQueue_t *const pQueue)
Remove an element at the head of the queue.
Definition: iot_ble_linear_containers.h:953
static IotLink_t * IotDeQueue_DequeueTail(IotDeQueue_t *const pQueue)
Remove an element at the tail of the queue.
Definition: iot_ble_linear_containers.h:983
static void IotListDouble_InsertBefore(IotLink_t *const pElement, IotLink_t *const pLink)
Insert an element before another element in a doubly-linked list.
Definition: iot_ble_linear_containers.h:498
static void IotDeQueue_EnqueueTail(IotDeQueue_t *const pQueue, IotLink_t *const pLink)
Add an element at the tail of the queue.
Definition: iot_ble_linear_containers.h:966
static void IotListDouble_RemoveAll(IotListDouble_t *const pList, void(*freeElement)(void *), size_t linkOffset)
Remove all elements in a doubly-linked list.
Definition: iot_ble_linear_containers.h:659
static size_t IotDeQueue_Count(const IotDeQueue_t *const pQueue)
Return the number of elements contained in an IotDeQueue_t.
Definition: iot_ble_linear_containers.h:874
static void IotListDouble_RemoveAllMatches(IotListDouble_t *const pList, bool(*isMatch)(const IotLink_t *, void *), void *pMatch, void(*freeElement)(void *), size_t linkOffset)
Remove all matching elements from a doubly-linked list.
Definition: iot_ble_linear_containers.h:812
static bool IotDeQueue_IsEmpty(const IotDeQueue_t *const pQueue)
Check if a queue is empty.
Definition: iot_ble_linear_containers.h:889
static void IotDeQueue_Remove(IotLink_t *const pLink)
Remove a single element from a queue.
Definition: iot_ble_linear_containers.h:995
static IotLink_t * IotListDouble_PeekHead(const IotListDouble_t *const pList)
Return an IotLink_t representing the first element in a doubly-linked list without removing it...
Definition: iot_ble_linear_containers.h:396
IotLink_t IotListDouble_t
Represents a doubly-linked list.
Definition: iot_ble_linear_containers.h:65
static IotLink_t * IotListDouble_RemoveHead(IotListDouble_t *const pList)
Remove the element at the head of a doubly-linked list.
Definition: iot_ble_linear_containers.h:609
static bool IotLink_IsLinked(const IotLink_t *const pLink)
Check if an IotLink_t is linked in a list or queue.
Definition: iot_ble_linear_containers.h:303
static void IotListDouble_InsertAfter(IotLink_t *const pElement, IotLink_t *const pLink)
Insert an element after another element in a doubly-linked list.
Definition: iot_ble_linear_containers.h:512
static void IotDeQueue_RemoveAllMatches(IotDeQueue_t *const pQueue, bool(*isMatch)(const IotLink_t *, void *), void *pMatch, void(*freeElement)(void *), size_t linkOffset)
Remove all matching elements from a queue.
Definition: iot_ble_linear_containers.h:1038