Revert "mes.c: use single malloc with arena."

This reverts commit 38c364faeff430a5ee28f402d24b073f6bf9a548.
This commit is contained in:
Jan Nieuwenhuizen 2016-09-25 10:13:09 +02:00
parent b955b84d20
commit 697858f670

30
mes.c
View file

@ -69,19 +69,6 @@ typedef struct scm_t {
#define MES_C 1
#include "mes.h"
char *g_arena;
int ARENA_SIZE = 1024 * 1024 * 1024;
void *
xmalloc (int size)
{
static char *arena_start = 0;
if (!arena_start) arena_start = g_arena;
assert (g_arena - arena_start + size < ARENA_SIZE);
char* x = g_arena;
g_arena += size;
return x;
}
scm *display_helper (FILE*, scm*, bool, char*, bool);
bool
symbol_eq (scm *x, char *s)
@ -153,7 +140,7 @@ cdr (scm *x)
scm *
cons (scm *x, scm *y)
{
scm *p = xmalloc (sizeof (scm));
scm *p = malloc (sizeof (scm));
p->type = PAIR;
p->car = x;
p->cdr = y;
@ -580,7 +567,7 @@ append (scm *x/*...*/)
scm *
make_char (int x)
{
scm *p = xmalloc (sizeof (scm));
scm *p = malloc (sizeof (scm));
p->type = CHAR;
p->value = x;
return p;
@ -589,7 +576,7 @@ make_char (int x)
scm *
make_macro (scm *x, char *name)
{
scm *p = xmalloc (sizeof (scm));
scm *p = malloc (sizeof (scm));
p->type = MACRO;
p->macro = x;
p->name = name;
@ -599,7 +586,7 @@ make_macro (scm *x, char *name)
scm *
make_number (int x)
{
scm *p = xmalloc (sizeof (scm));
scm *p = malloc (sizeof (scm));
p->type = NUMBER;
p->value = x;
return p;
@ -608,7 +595,7 @@ make_number (int x)
scm *
make_string (char const *s)
{
scm *p = xmalloc (sizeof (scm));
scm *p = malloc (sizeof (scm));
p->type = STRING;
p->name = strdup (s);
return p;
@ -618,7 +605,7 @@ scm *
make_symbol (char const *s)
{
// TODO: alist lookup symbols
scm *p = xmalloc (sizeof (scm));
scm *p = malloc (sizeof (scm));
p->type = SYMBOL;
p->name = strdup (s);
return p;
@ -627,10 +614,10 @@ make_symbol (char const *s)
scm *
make_vector (int n)
{
scm *p = xmalloc (sizeof (scm));
scm *p = malloc (sizeof (scm));
p->type = VECTOR;
p->length = n;
p->vector = xmalloc (n * sizeof (scm*));
p->vector = malloc (n * sizeof (scm*));
return p;
}
@ -1428,7 +1415,6 @@ read_file (scm *e, scm *a)
int
main (int argc, char *argv[])
{
g_arena = malloc (ARENA_SIZE);
scm *a = mes_environment ();
display_ (stderr, eval (cons (&symbol_begin, read_file (readenv (a), a)), a));
fputs ("", stderr);