libUPnP
1.6.17
|
Go to the source code of this file.
Data Structures | |
struct | FREELISTNODE |
struct | FREELIST |
Typedefs | |
typedef struct FREELISTNODE | FreeListNode |
typedef struct FREELIST | FreeList |
Functions | |
int | FreeListInit (FreeList *free_list, size_t elementSize, int maxFreeListLength) |
Initializes Free List. | |
void * | FreeListAlloc (FreeList *free_list) |
Allocates chunk of set size. | |
int | FreeListFree (FreeList *free_list, void *element) |
Returns an item to the Free List. | |
int | FreeListDestroy (FreeList *free_list) |
Releases the resources stored with the free list. |
Stores head and size of free list, as well as mutex for protection.
typedef struct FREELISTNODE FreeListNode |
Free list node. points to next free item. Memory for node is borrowed from allocated items.
void* FreeListAlloc | ( | FreeList * | free_list | ) |
Allocates chunk of set size.
If a free item is available in the list, returnes the stored item, otherwise calls the O.S. to allocate memory.
free_list | Must be valid, non null, pointer to a linked list. |
References FreeListAlloc().
Referenced by CreateThreadPoolJob(), CreateTimerEvent(), and FreeListAlloc().
int FreeListDestroy | ( | FreeList * | free_list | ) |
Releases the resources stored with the free list.
0
on success. EINVAL
on failure. free_list | Must be valid, non null, pointer to a linked list. |
References FreeListDestroy().
Referenced by FreeListDestroy(), ListDestroy(), ThreadPoolShutdown(), TimerThreadInit(), and TimerThreadShutdown().
int FreeListFree | ( | FreeList * | free_list, |
void * | element | ||
) |
Returns an item to the Free List.
If the free list is smaller than the max size then adds the item to the free list, otherwise returns the item to the O.S.
0
on success. EINVAL
on failure. free_list | Must be valid, non null, pointer to a free list. |
element | Must be a pointer allocated by FreeListAlloc. |
References FreeListFree().
Referenced by FreeListFree(), FreeThreadPoolJob(), and FreeTimerEvent().
int FreeListInit | ( | FreeList * | free_list, |
size_t | elementSize, | ||
int | maxFreeListLength | ||
) |
Initializes Free List.
Must be called first and only once for FreeList.
0
on success. EINVAL
on failure. free_list | Must be valid, non null, pointer to a linked list. |
elementSize | Size of elements to store in free list. |
maxFreeListLength | Max size that the free list can grow to before returning memory to O.S. |
References FreeListInit().
Referenced by FreeListInit(), ListInit(), ThreadPoolInit(), and TimerThreadInit().