#include <inttypes.h>
#include <stdlib.h>
#include "task.h"
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_BLOCK * | HeapInit (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 STACK_POINTER | ( | ) | ((char *)SP) |
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.
pHB | pointer to a heap block object | |
len | size of desired memory block |
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.
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.
pHeap | pointer to HEAP_BLOCK to check for free memory |
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.
start | pointer to start of memory to use for heap | |
end | pointer to end of memory to use for heap |
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().
char* __brkval |
struct __freelist* __flp |
char __heap_end |
char __heap_start |
char* __malloc_heap_end |
char* __malloc_heap_start |
size_t __malloc_margin |