Documentation from genheap.h | ![]() |
![]() | |
Introduction | [top] |
ROV - Easy applications from C
Copyright - © Jason Tribbeck / 7th ARM 1994-2001
Contributing authors - Jason Tribbeck
File - genheap.h
Type - subsystem
Description
The genheap subsystem allows applications to maintain multiple heaps of malloc-style data, ostensively for keeping multiple files with their own memory areas.
![]() | |
genheap_init | [top] |
Initialise a memory heap.
Parameters:
- void *heap_ptr - the pointer to the heap.
- int heap_size - the size of the heap.void genheap_init(void *heap_ptr, int heap_size);
![]() | |
genheap_malloc | [top] |
Allocate memory in a heap.
Parameters:
- void *heap_ptr - the pointer to the heap.
- int heap_size - the size of the heap.
- int size - the size to allocate.Returns:
- the pointer in the heap, or NULL if failed.
void *genheap_malloc(void *heap_ptr, int heap_size, int size);
![]() | |
genheap_free | [top] |
Free memory in a heap.
Parameters:
- void *heap_ptr - the pointer to the heap.
- int heap_size - the size of the heap.
- void *ptr - the pointer to the memory to free.void genheap_free(void *heap_ptr, int heap_size, void * ptr);
![]() | |
genheap_freespace | [top] |
Get the free space in the heap.
Parameters:
- void *heap_ptr - the pointer to the heap.
- int heap_size - the size of the heap.Returns:
- the free space in the heap.
int genheap_freespace(void *heap_ptr, int heap_size);
![]() | |
genheap_resize | [top] |
Resize a heap.
Parameters:
- void *heap_ptr - the pointer to the heap.
- int old_size - the old size.
- int new_size - the new size.Note - This does not perform any form of memory allocation on the heap, so this must have been done beforehand.
Note - If the new size is smaller than the allocated size, then it is truncated.
void genheap_resize(void *heap_ptr, int old_size, int new_size);
![]() | |
genheap_walk | [top] |
Walk through the heap.
Parameters:
- void *heap_ptr - the pointer to the heap.
- int heap_size - the heap size.
- void *chunk - the pointer to the current heap chunk (or NULL to start).Returns:
- the next heap chunk (or NULL for no more).
void * genheap_walk(void *heap_ptr, int heap_size, void *chunk);See also: genheap_size(), genheap_type()
![]() | |
genheap_size | [top] |
Get the size of the heap chunk
Parameters:
- void *chunk - the pointer to the heap chunk.
Returns:
- the size of the memory allocated.
int genheap_size(void *chunk);See also: genheap_type(), genheap_walk()
![]() | |
genheap_type | [top] |
Get the type of the heap chunk
Parameters:
- void *chunk - the pointer to the heap chunk.
Returns:
- the type ('f' is a free chunk, 'a' is an allocated chunk).
char genheap_type(void *chunk);See also: genheap_size(), genheap_walk()
Generated Thu Feb 7 23:22:51 2002