# SFBHeap Class Reference

A minimal heap memory allocator, based on the ancient K&R approach. More...

`#include <SFBHeap.h>`

Collaboration diagram for SFBHeap:

[legend]

## Data Structures
union | HeapHeader
## Public Types
enum | { HEAP_SIZE_HEADERS = 1<<8, HEAP_SIZE_BYTES = HEAP_SIZE_HEADERS<<3, FREE_CHECK_BYTES = 0x5aa5, USED_CHECK_BYTES = 0xaa55 }
## Public Member Functions
void * | malloc (u32 bytes)
void | free (void *packet)
u8 * | remember (const u8 *packet, bool unreadOnly=false, u8 sourceOverride=MAX_FACE_INDEX)
u8 * | rememberBytes (const u8 *bytePtr, u32 byteCount)
void | forget (u8 *packet)
u8 * | makePacket (u32 size)

## Detailed Description

A minimal heap memory allocator, based on the ancient K&R approach.

There are 'malloc()' and 'free()' methods in this class, but since the size of the underlying heap is fixed and only 1KB in size, it will typically be at least extremely frustrating, if not simply impossible, to use these methods in a conventional 'general purpose dynamic memory' programming style.

Note that even a

     malloc(1)

burns 16 bytes -- at _best_, no more than 64 non-empty malloced blocks can be active at once!

SBFHeap exists primarily to support SFBMemory, which provides a mechanism for temporary storage of packets.

The documentation for this class was generated from the following files:

- src/include/SFBHeap.h
- src/components/library/SFBHeap.cpp