E:/Projects/AvrLib/include/HeapManager.h File Reference

#include <inttypes.h>
#include <stdlib.h>
#include "task.h"

Include dependency graph for HeapManager.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  __freelist
struct  HEAP_BLOCK
#define STACK_POINTER()   ((char *)SP)
char * __brkval
struct __freelist__flp
size_t __malloc_margin
char * __malloc_heap_start
char * __malloc_heap_end
char __heap_start
char __heap_end
HEAP_BLOCKHeapInit (char *start, char *end)
 Initialize a heap block object.
void * HeapAlloc (HEAP_BLOCK *pHB, size_t len)
 This function is used to allocate memory from a heap.
void HeapFree (HEAP_BLOCK *pHB, void *p)
 Free a block of memory back to a heap.
size_t HeapFreeSpace (HEAP_BLOCK *pHB)
 This function tells us how much free memory is available for allocation.


Define Documentation

 
#define STACK_POINTER (  )     ((char *)SP)

Definition at line 60 of file HeapManager.h.

Referenced by HeapAlloc().


Function Documentation

void * HeapAlloc ( HEAP_BLOCK pHB,
size_t  len 
)

This function is used to allocate memory from a heap.

The code for this function was lifted directly out of the WINAVR libc library. This was originally malloc writen by Joerg Wunsch and modified by Jim Patchell to turn it into a bit more of an object oriented function. The object is a HEAP_BLOCK.

Parameters:
pHB pointer to a heap block object
len size of desired memory block
Returns:
pointer to memory block, or NULL on FAIL!

Definition at line 68 of file heapmanager.c.

References HEAP_BLOCK::__flp, HEAP_BLOCK::Blocker, HEAP_BLOCK::BrkVal, HEAP_BLOCK::End, HEAP_BLOCK::Margin, __freelist::nx, PendSemaphore(), PostSemaphore(), STACK_POINTER, HEAP_BLOCK::Start, and __freelist::sz.

Referenced by AllocStack().

void HeapFree ( HEAP_BLOCK pHB,
void *  p 
)

Free a block of memory back to a heap.

The code for this function was lifted directly out of the WINAVR libc library. This was originally malloc writen by Joerg Wunsch and modified by Jim Patchell to turn it into a bit more of an object oriented function. The object is a HEAP_BLOCK.

Parameters:
pHB pointer to a HEAP_BLOCK object to free memory to
p pointer to the block of memory to free

Definition at line 209 of file heapmanager.c.

References HEAP_BLOCK::__flp, HEAP_BLOCK::Blocker, __freelist::nx, PendSemaphore(), PostSemaphore(), and __freelist::sz.

size_t HeapFreeSpace ( HEAP_BLOCK pHeap  ) 

This function tells us how much free memory is available for allocation.

Parameters:
pHeap pointer to HEAP_BLOCK to check for free memory
Returns:
number of bytes availiable for allocation

Definition at line 18 of file HeapFreeSpace.c.

References HEAP_BLOCK::__flp, HEAP_BLOCK::BrkVal, HEAP_BLOCK::End, __freelist::nx, HEAP_BLOCK::Start, and __freelist::sz.

Referenced by StackHeapAvailiable().

HEAP_BLOCK * HeapInit ( char *  start,
char *  end 
)

Initialize a heap block object.

this function is used to initialize a heap block. The user passes this function a pointer to the start and end if a block of memory that is going to be used as the heap. This function does a lot of things to that memory. One is to create a semaphore in the block of memory so that calling HeapAlloc and HeapFree will be thread safe.

So, one must remember that not all of the block will be available for allocation.

Parameters:
start pointer to start of memory to use for heap
end pointer to end of memory to use for heap
Returns:
pointer to HEAP_BLOCK object upon success

Definition at line 298 of file heapmanager.c.

References HEAP_BLOCK::__flp, HEAP_BLOCK::Blocker, HEAP_BLOCK::BrkVal, CreateSemaphore(), HEAP_BLOCK::End, HEAP_BLOCK::Margin, SEMAPHORE_MODE_BLOCKING, and HEAP_BLOCK::Start.

Referenced by OSInit().


Variable Documentation

char* __brkval

struct __freelist* __flp

char __heap_end


Generated on Sun Aug 31 13:30:28 2008 for FrankenRTOS by  doxygen 1.5.6