UPnPsdk 0.1
Universal Plug and Play +, Software Development Kit
 
Loading...
Searching...
No Matches
FreeList.hpp
Go to the documentation of this file.
1#ifndef COMPA_FREE_LIST_HPP
2#define COMPA_FREE_LIST_HPP
3/*******************************************************************************
4 *
5 * Copyright (c) 2000-2003 Intel Corporation
6 * All rights reserved.
7 * Copyright (C) 2021+ GPL 3 and higher by Ingo Höft, <Ingo@Hoeft-online.de>
8 * Redistribution only with this Copyright remark. Last modified: 2025-04-30
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
12 *
13 * * Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 * * Neither name of Intel Corporation nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
26 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
30 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 ******************************************************************************/
44#include <UPnPsdk/pthread.hpp>
46#include <cerrno>
48
56 struct FreeListNode* next;
57};
58
63struct FreeList {
64 FreeListNode* head;
65 size_t element_size;
66 int maxFreeListLength;
67 int freeListLength;
68};
69
79int FreeListInit(
81 FreeList* free_list,
83 size_t elementSize,
86 int maxFreeListLength);
87
98void* FreeListAlloc(
100 FreeList* free_list);
101
112int FreeListFree(
114 FreeList* free_list,
116 void* element);
117
127 FreeList* free_list);
128
129#endif /* COMPA_FREE_LIST_HPP */
int FreeListInit(FreeList *free_list, size_t elementSize, int maxFreeListLength)
Initializes Free List.
Definition FreeList.cpp:50
int FreeListFree(FreeList *free_list, void *element)
Returns an item to the Free List.
Definition FreeList.cpp:83
void * FreeListAlloc(FreeList *free_list)
Allocates chunk of set size.
Definition FreeList.cpp:64
int FreeListDestroy(FreeList *free_list)
Releases the resources stored with the free list.
Definition FreeList.cpp:103
Free list node. points to next free item.
Definition FreeList.hpp:55
Stores head and size of free list, as well as mutex for protection.
Definition FreeList.hpp:63
Additional functions to manage Posix threads with C++ to be portable.