libUPnP  1.6.17
Data Structures | Typedefs | Functions
FreeList.h File Reference
#include "ithread.h"
#include <errno.h>
Include dependency graph for FreeList.h:
This graph shows which files directly or indirectly include this file:

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.

Detailed Description


Typedef Documentation

typedef struct FREELIST FreeList

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.


Function Documentation

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.

Returns:
Non NULL on success. NULL on failure.
Parameters:
free_listMust 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.

Returns:
:
  • 0 on success.
  • EINVAL on failure.
Parameters:
free_listMust 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.

Returns:
:
  • 0 on success.
  • EINVAL on failure.
Parameters:
free_listMust be valid, non null, pointer to a free list.
elementMust 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.

Returns:
:
  • 0 on success.
  • EINVAL on failure.
Parameters:
free_listMust be valid, non null, pointer to a linked list.
elementSizeSize of elements to store in free list.
maxFreeListLengthMax size that the free list can grow to before returning memory to O.S.

References FreeListInit().

Referenced by FreeListInit(), ListInit(), ThreadPoolInit(), and TimerThreadInit().