(wrong string) ée

From: <git_AT_suckless.org>
Date: Sun, 1 May 2016 10:34:08 +0200 (CEST)

commit 5532b46827067fdfe3dfe35f114c57084c6f5717
Author: Mattias Andrée <maandree_AT_kth.se>
AuthorDate: Sun May 1 10:33:53 2016 +0200
Commit: Mattias Andrée <maandree_AT_kth.se>
CommitDate: Sun May 1 10:33:53 2016 +0200

    Constants do not need dynamic memory
    
    Signed-off-by: Mattias Andrée <maandree_AT_kth.se>

diff --git a/src/internals.h b/src/internals.h
index 407f4b7..841346f 100644
--- a/src/internals.h
+++ b/src/internals.h
_AT_@ -51,15 +51,15 @@
         X(libzahl_tmp_ptest_n4, 0)
 
 #define LIST_CONSTS\
- X(libzahl_const_1e19, zsetu, 10000000000000000000ULL) /* The largest power of 10 < 2⁶⁴. */\
- X(libzahl_const_1, zsetu, 1)\
- X(libzahl_const_2, zsetu, 2)\
- X(libzahl_const_4, zsetu, 4)
+ X(0, libzahl_const_1e19, zsetu, 10000000000000000000ULL) /* The largest power of 10 < 2⁶⁴. */\
+ X(1, libzahl_const_1, zsetu, 1)\
+ X(2, libzahl_const_2, zsetu, 2)\
+ X(3, libzahl_const_4, zsetu, 4)
 
 #define X(x, s) extern z_t x;
 LIST_TEMPS
 #undef X
-#define X(x, f, v) extern z_t x;
+#define X(i, x, f, v) extern z_t x;
 LIST_CONSTS
 #undef X
 
diff --git a/src/zsetup.c b/src/zsetup.c
index 66d94ee..3e3062b 100644
--- a/src/zsetup.c
+++ b/src/zsetup.c
_AT_@ -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
 
_AT_@ -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)
_AT_@ -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--;)
diff --git a/src/zunsetup.c b/src/zunsetup.c
index 48ee9e3..0af3968 100644
--- a/src/zunsetup.c
+++ b/src/zunsetup.c
_AT_@ -12,10 +12,6 @@ zunsetup(void)
                 free(x->chars);
                 LIST_TEMPS;
 #undef X
-#define X(x, f, v)\
- free(x->chars);
- LIST_CONSTS;
-#undef X
                 for (i = BITS_PER_CHAR; i--;)
                         free(libzahl_tmp_divmod_ds[i]->chars);
 
Received on Sun May 01 2016 - 10:34:08 CEST

This archive was generated by hypermail 2.3.0 : Sun May 01 2016 - 10:36:15 CEST