2013-03-13 17:11:23 +04:00
|
|
|
#ifndef _IDRIS_HEAP_H
|
|
|
|
#define _IDRIS_HEAP_H
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char* next; // Next allocated chunk. Should always (heap <= next < end).
|
|
|
|
char* heap; // Point to bottom of heap
|
|
|
|
char* end; // Point to top of heap
|
|
|
|
size_t size; // Size of _next_ heap. Size of current heap is /end - heap/.
|
2013-03-15 21:01:55 +04:00
|
|
|
size_t growth; // Quantity of heap growth in bytes.
|
2013-03-13 17:11:23 +04:00
|
|
|
|
|
|
|
char* old;
|
|
|
|
} Heap;
|
|
|
|
|
2013-03-13 21:17:53 +04:00
|
|
|
|
2015-03-01 00:41:22 +03:00
|
|
|
void alloc_heap(Heap * heap, size_t heap_size, size_t growth, char * old);
|
2013-03-13 17:11:23 +04:00
|
|
|
void free_heap(Heap * heap);
|
|
|
|
|
2013-03-13 21:17:53 +04:00
|
|
|
|
|
|
|
#ifdef IDRIS_DEBUG
|
|
|
|
void heap_check_all(Heap * heap);
|
|
|
|
// Should be used _between_ gc's.
|
|
|
|
#define HEAP_CHECK(vm) heap_check_all(&(vm->heap));
|
|
|
|
#else
|
|
|
|
#define HEAP_CHECK(vm)
|
|
|
|
#endif // IDRIS_DEBUG
|
|
|
|
|
|
|
|
#endif // _IDRIS_HEAP_H
|