UPnPsdk 0.1
Universal Plug and Play +, Software Development Kit
 
Loading...
Searching...
No Matches

Manage a free list (for internal use only). More...

#include "FreeList.hpp"
#include <umock/stdlib.hpp>
+ Include dependency graph for FreeList.cpp:

Go to the source code of this file.

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.
 

Detailed Description

Manage a free list (for internal use only).

Because this is for internal use, parameters are NOT checked for validity. The caller must ensure valid parameters.

Definition in file FreeList.cpp.

Function Documentation

◆ FreeListInit()

int FreeListInit ( FreeList free_list,
size_t  elementSize,
int  maxFreeListLength 
)

Initializes Free List.

Must be called first and only once for FreeList.

Returns
On success: 0
On error: EINVAL
Parameters
[in]free_listMust be valid, non null, pointer to a linked list.
[in]elementSizeSize of elements to store in free list.
[in]maxFreeListLengthMax size that the free list can grow to before returning memory to the operating system

Definition at line 50 of file FreeList.cpp.

+ Here is the caller graph for this function:

◆ FreeListAlloc()

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 operating system to allocate memory.

Returns
On success: Non nullptr
On error: nullptr
Parameters
[in]free_listMust be valid, non null, pointer to a linked list.

Definition at line 64 of file FreeList.cpp.

+ Here is the caller graph for this function:

◆ FreeListFree()

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 operating system.

Returns
On success: 0
On error: EINVAL
Parameters
[in]free_listMust be valid, non null, pointer to a free list.
[in]elementMust be a pointer allocated by FreeListAlloc.

Definition at line 83 of file FreeList.cpp.

+ Here is the caller graph for this function:

◆ FreeListDestroy()

int FreeListDestroy ( FreeList free_list)

Releases the resources stored with the free list.

Returns
On success: 0
On error: EINVAL
Parameters
[in]free_listMust be valid, non null, pointer to a linked list.

Definition at line 103 of file FreeList.cpp.

+ Here is the caller graph for this function: