aboutsummaryrefslogtreecommitdiff
path: root/malloc.c
blob: 3ab95ed9927ed4b17f7c9db73bd7e824f69aaf6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <inttypes.h>
#include "string.h"

extern uint8_t edata;
static uint8_t *fseg_base = &edata;

extern uint8_t stext;
static uint8_t *malloc_top = &stext;

void *malloc(int n)
{
	malloc_top -= (n + 15) & -16;
	return malloc_top;
}

void *malloc_fseg(int n)
{
	void *p = fseg_base;
	fseg_base += (n + 15) & -16;
	return p;
}