From 898e9ecf2a0bc49f012df20ed92b6c49784187a6 Mon Sep 17 00:00:00 2001 From: Andrei Lascu Date: Thu, 26 Sep 2024 15:15:13 +0100 Subject: [PATCH] Verbosity --- include/symbols.h | 2 ++ src/symbols_comp.c | 4 ++-- src/symbols_lib.c | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/symbols.h b/include/symbols.h index ed88b79..cd03789 100644 --- a/include/symbols.h +++ b/include/symbols.h @@ -13,4 +13,6 @@ #define HASHTABLE_MAX_SZ 1024 #define hashtable_hash(x) tommy_hash_u64(0, x, strlen(x)) +#define MAX_FIND_ALL_COUNT 1024 + #endif // _CHERICOMP_SYMBOLS_H diff --git a/src/symbols_comp.c b/src/symbols_comp.c index 2f9ade2..afbfeb3 100644 --- a/src/symbols_comp.c +++ b/src/symbols_comp.c @@ -80,7 +80,7 @@ comp_syms_search(const char *to_find, comp_symbol_list *list) comp_symbol ** comp_syms_find_all(const char *to_find, comp_symbol_list *list) { - comp_symbol** res = calloc(1024, sizeof(comp_symbol*)); + comp_symbol** res = calloc(MAX_FIND_ALL_COUNT, sizeof(comp_symbol*)); unsigned int res_sz = 0; tommy_hashtable_node* curr_node = tommy_hashtable_bucket(list, hashtable_hash(to_find)); while (curr_node) @@ -92,7 +92,7 @@ comp_syms_find_all(const char *to_find, comp_symbol_list *list) } curr_node = curr_node->next; } - assert(res_sz < 1024); + assert(res_sz < MAX_FIND_ALL_COUNT - 1); res = realloc(res, (res_sz + 1) * sizeof(comp_symbol*)); return res; } diff --git a/src/symbols_lib.c b/src/symbols_lib.c index 03caded..ba6854a 100644 --- a/src/symbols_lib.c +++ b/src/symbols_lib.c @@ -81,7 +81,7 @@ lib_syms_search(const char *to_find, lib_symbol_list *list) lib_symbol ** lib_syms_find_all(const char *to_find, lib_symbol_list *list) { - lib_symbol** res = calloc(1024, sizeof(lib_symbol*)); + lib_symbol** res = calloc(MAX_FIND_ALL_COUNT, sizeof(lib_symbol*)); unsigned int res_sz = 0; tommy_hashtable_node* curr_node = tommy_hashtable_bucket(list, hashtable_hash(to_find)); while (curr_node) @@ -93,7 +93,7 @@ lib_syms_find_all(const char *to_find, lib_symbol_list *list) } curr_node = curr_node->next; } - assert(res_sz < 1024); + assert(res_sz < MAX_FIND_ALL_COUNT - 1); res = realloc(res, (res_sz + 1) * sizeof(lib_symbol*)); return res; }