blob: 7a938e0cdfbc7c825bf03ccb0f9cecdab7917d33 (
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
|
#include "arena.h"
#include "minilib.h"
#include "io.h"
static char p[ARENA_SIZE];
static char *ptr = p;
void *allocate( int size )
{
char *m;
if( ptr - p + size < ARENA_SIZE ) {
m = ptr;
ptr = ptr + size;
return m;
}
print( "OUT OF MEMORY" );
halt( );
}
void deallocate( void **p )
{
if( *p == 0 ) {
print( "DEALLOCATING ALREADY FREED POINTER" );
halt( );
}
*p = 0;
}
|