GBDK 2020 Docs API Documentation for GBDK 2020

Data Structures | Macros | Typedefs | Functions | Variables
malloc.h File Reference
`#include <types.h>`

Go to the source code of this file.

## Data Structures
struct | smalloc_hunk

## Macros
#define | MALLOC_FREE 1
#define | MALLOC_USED 2
#define | MALLOC_MAGIC 123

## Typedefs
typedef struct smalloc_hunk | mmalloc_hunk
typedef struct smalloc_hunk * | pmmalloc_hunk

## Functions
void | malloc_gc (void) NONBANKED
void | debug (char *routine, char *msg) NONBANKED

## Variables
UBYTE | malloc_heap_start
pmmalloc_hunk | malloc_first

## Detailed Description

Header for a simple implementation of malloc().

Todo:
  : This library may currently be broken.

## Macro Definition Documentation

## ◆ MALLOC_FREE

#define MALLOC_FREE 1

The malloc hunk flags Note: Cound have used a negative size a'la TI

## ◆ MALLOC_USED

#define MALLOC_USED 2

## ◆ MALLOC_MAGIC

#define MALLOC_MAGIC 123

Magic number of a header. Gives us some chance of surviving if the list is corrupted

## Typedef Documentation

## ◆ mmalloc_hunk

typedef struct smalloc_hunk mmalloc_hunk

## ◆ pmmalloc_hunk

typedef struct smalloc_hunk* pmmalloc_hunk

## Function Documentation

## ◆ malloc_gc()

void malloc_gc | ( | void |  | ) |

Garbage collect (join free hunks)

## ◆ debug()

void debug | ( | char * | routine,
|  | char * | msg
| ) |  |

debug message logger

## Variable Documentation

## ◆ malloc_heap_start

UBYTE malloc_heap_start
| extern

Start of free memory, as defined by the linker

## ◆ malloc_first

pmmalloc_hunk malloc_first
| extern

First hunk