UPnPsdk 0.1
Universal Plug and Play +, Software Development Kit
 
Loading...
Searching...
No Matches
list.cpp
Go to the documentation of this file.
1/*******************************************************************************
2 *
3 * Copyright (c) 2000-2003 Intel Corporation
4 * All rights reserved.
5 * Copyright (C) 2011-2012 France Telecom All rights reserved.
6 * Copyright (C) 2021 GPL 3 and higher by Ingo Höft, <Ingo@Hoeft-online.de>
7 * Redistribution only with this Copyright remark. Last modified: 2025-05-24
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 * * Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright notice,
15 * this list of conditions and the following disclaimer in the documentation
16 * and/or other materials provided with the distribution.
17 * * Neither name of Intel Corporation nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
25 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
29 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 ******************************************************************************/
42#include <list.hpp>
43
45 if (list) {
46 list->next = list;
47 list->prev = list;
48 }
49}
50
52 if (list)
53 return list->next;
54 else
55 return nullptr;
56}
57
58UpnpListIter UpnpListEnd(UpnpListHead* list) { return list; }
59
60UpnpListIter UpnpListNext([[maybe_unused]] UpnpListHead* list,
61 UpnpListIter pos) {
62 if (pos)
63 return pos->next;
64 else
65 return nullptr;
66}
67
69 UpnpListIter pos, UpnpListHead* elt) {
70 if (pos && elt) {
71 elt->prev = pos->prev;
72 elt->next = pos;
73 pos->prev->next = elt;
74 pos->prev = elt;
75 return elt;
76 } else
77 return nullptr;
78}
79
81 UpnpListIter pos) {
82 if (pos) {
83 pos->prev->next = pos->next;
84 pos->next->prev = pos->prev;
85 return pos->next;
86 } else
87 return nullptr;
88}
void UpnpListInit(UpnpListHead *list)
Initialize empty list.
Definition list.cpp:44
UpnpListIter UpnpListEnd(UpnpListHead *list)
Return end of list sentinel iterator (not an element)
Definition list.cpp:58
UpnpListIter UpnpListInsert(UpnpListHead *list, UpnpListIter pos, UpnpListHead *elt)
Insert element before pos, returns iterator pointing to inserted element.
Definition list.cpp:68
UpnpListIter UpnpListErase(UpnpListHead *list, UpnpListIter pos)
Erase element at pos, return next one, or end()
Definition list.cpp:80
UpnpListIter UpnpListBegin(UpnpListHead *list)
Return iterator pointing to the first list element, or UpnpListEnd(list) if the list is empty.
Definition list.cpp:51
UpnpListIter UpnpListNext(UpnpListHead *list, UpnpListIter pos)
Return iterator pointing to element after pos, or end()
Definition list.cpp:60
Trivial list management interface, patterned on std::list.
struct UpnpListHead * prev
Points to previous entry in the list.
Definition list.hpp:58
struct UpnpListHead * next
Points to next entry in the list.
Definition list.hpp:57
List anchor structure.
Definition list.hpp:56