Commit 522af3e77dfbe618cbc8d982ecceee77d8ea8127

Thomas de Grivel 2020-09-07T12:47:46

fix symtable realloc

diff --git a/symtable.c b/symtable.c
index 67b0038..1945620 100644
--- a/symtable.c
+++ b/symtable.c
@@ -26,7 +26,7 @@ void symtable_init (s_symtable *st)
 {
   assert(st);
   st->count = 0;
-  st->size = 128;
+  st->size = 64;
   if (!(st->sym = calloc(st->size, sizeof(t_sym))))
     err(10, "symtable_init calloc");
 }
@@ -64,8 +64,8 @@ void symtable_free_all (s_symtable *st)
 void symtable_enlarge (s_symtable *st)
 {
   assert(st);
-  st->size += st->size < 1024 ? st->size : 1024;
-  if (!(st->sym = realloc(st->sym, st->size)))
+  st->size += 64;
+  if (!(st->sym = realloc(st->sym, st->size * sizeof(t_sym))))
     err(10, "symtable realloc");
   assert(st->size > st->count);
 }