diff options
| author | Mattias Andrée <maandree@kth.se> | 2016-05-01 10:33:53 +0200 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2016-05-01 10:33:53 +0200 |
| commit | 5532b46827067fdfe3dfe35f114c57084c6f5717 (patch) | |
| tree | 03d778f90faf5921bff8e50ca1ac8d5a7806b10d /src/zsetup.c | |
| parent | zdiv.3: rationale for truncated division (diff) | |
| download | libzahl-5532b46827067fdfe3dfe35f114c57084c6f5717.tar.gz libzahl-5532b46827067fdfe3dfe35f114c57084c6f5717.tar.bz2 libzahl-5532b46827067fdfe3dfe35f114c57084c6f5717.tar.xz | |
Constants do not need dynamic memory
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/zsetup.c')
| -rw-r--r-- | src/zsetup.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/zsetup.c b/src/zsetup.c index 66d94ee..3e3062b 100644 --- a/src/zsetup.c +++ b/src/zsetup.c @@ -4,7 +4,7 @@ #define X(x, s) z_t x; LIST_TEMPS #undef X -#define X(x, f, v) z_t x; +#define X(i, x, f, v) z_t x; LIST_CONSTS #undef X @@ -20,6 +20,10 @@ struct zahl **libzahl_temp_stack_head; struct zahl **libzahl_temp_stack_end; void *libzahl_temp_allocation = 0; +#define X(i, x, f, v) 1 + +static zahl_char_t constant_chars[LIST_CONSTS 0]; +#undef X + void zsetup(jmp_buf env) @@ -38,8 +42,8 @@ zsetup(jmp_buf env) zinit(x); if (s) zsetu(x, 1); LIST_TEMPS; #undef X -#define X(x, f, v)\ - zinit(x), f(x, v); +#define X(i, x, f, v)\ + (x)->alloced = 1, (x)->chars = constant_chars + (i), f(x, v); LIST_CONSTS; #undef X for (i = BITS_PER_CHAR; i--;) |
