diff options
| author | Keith Packard <keithp@keithp.com> | 2016-11-18 21:14:47 -0800 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2017-02-20 11:16:52 -0800 | 
| commit | ecef616599d5ec4fd5d42e67d0dc779a0630079b (patch) | |
| tree | f25d37aac5002a23343b5d016bf4f0debcd208f0 /src/lisp/ao_lisp_mem.c | |
| parent | 4c812b8c903bd7e689572f8800ecc092af9cfe18 (diff) | |
altos/lisp: Use poly stashes for stacks
Saves some memory.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/lisp/ao_lisp_mem.c')
| -rw-r--r-- | src/lisp/ao_lisp_mem.c | 49 | 
1 files changed, 14 insertions, 35 deletions
| diff --git a/src/lisp/ao_lisp_mem.c b/src/lisp/ao_lisp_mem.c index 0dfad1d7..2599f719 100644 --- a/src/lisp/ao_lisp_mem.c +++ b/src/lisp/ao_lisp_mem.c @@ -144,8 +144,7 @@ struct ao_lisp_root {  static struct ao_lisp_cons 	*save_cons[2];  static char			*save_string[2]; -static struct ao_lisp_stack	*save_stack[3]; -static ao_poly			save_poly[2]; +static ao_poly			save_poly[3];  static const struct ao_lisp_root	ao_lisp_root[] = {  	{ @@ -157,24 +156,12 @@ static const struct ao_lisp_root	ao_lisp_root[] = {  		.addr = (void **) &save_cons[1],  	},  	{ -		.type = &ao_lisp_stack_type, -		.addr = (void **) &save_stack[0] -	}, -	{ -		.type = &ao_lisp_stack_type, -		.addr = (void **) &save_stack[1] -	}, -	{ -		.type = &ao_lisp_stack_type, -		.addr = (void **) &save_stack[2] -	}, -	{  		.type = &ao_lisp_string_type, -		.addr = (void **) &save_string[0] +		.addr = (void **) &save_string[0],  	},  	{  		.type = &ao_lisp_string_type, -		.addr = (void **) &save_string[1] +		.addr = (void **) &save_string[1],  	},  	{  		.type = NULL, @@ -185,6 +172,10 @@ static const struct ao_lisp_root	ao_lisp_root[] = {  		.addr = (void **) &save_poly[1]  	},  	{ +		.type = NULL, +		.addr = (void **) &save_poly[2] +	}, +	{  		.type = &ao_lisp_atom_type,  		.addr = (void **) &ao_lisp_atoms  	}, @@ -833,17 +824,17 @@ ao_lisp_cons_fetch(int id)  }  void -ao_lisp_stack_stash(int id, struct ao_lisp_stack *stack) +ao_lisp_poly_stash(int id, ao_poly poly)  { -	save_stack[id] = stack; +	save_poly[id] = poly;  } -struct ao_lisp_stack * -ao_lisp_stack_fetch(int id) +ao_poly +ao_lisp_poly_fetch(int id)  { -	struct ao_lisp_stack *stack = save_stack[id]; -	save_stack[id] = NULL; -	return stack; +	ao_poly poly = save_poly[id]; +	save_poly[id] = AO_LISP_NIL; +	return poly;  }  void @@ -859,16 +850,4 @@ ao_lisp_string_fetch(int id)  	save_string[id] = NULL;  	return string;  } -void -ao_lisp_poly_stash(int id, ao_poly poly) -{ -	save_poly[id] = poly; -} -ao_poly -ao_lisp_poly_fetch(int id) -{ -	ao_poly poly = save_poly[id]; -	save_poly[id] = AO_LISP_NIL; -	return poly; -} | 
