summaryrefslogtreecommitdiff
path: root/include/pso/THeap.h
blob: 6a94dee1ebc57c8bc477f4dc7edfd7b2d8e5783b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef THEAP_H
#define THEAP_H

#include "pso/forward.h"
#include "pso/macros.h"
#include <global_types.h>
#include <stdlib.h>

void heap_xfree(void *ptr);
void *heap_xmalloc(size_t size);

extern THeap *obj_heap;
extern THeap *alt_heap;

class THeap {
public:
	struct heap_node {
		heap_node *next;
		size_t remaining_size;
	};
	heap_node *heap_nodes;
	size_t mbr_0x04;
	size_t align;
	size_t mbr_0x0C;
	size_t mbr_0x10;
public:
	THeap(size_t size, int align);
	~THeap();
	void *operator new(size_t size) { return heap_xmalloc(size); };
	void operator delete(void *ptr) { heap_xfree(ptr); };
	void *heap_alloc(size_t size);
	void *heap_zalloc(size_t size);
	void heap_free(void *ptr);
};
#endif