Oh boy do I love formatting.

This commit is contained in:
Jacob Signorovitch 2025-03-26 18:16:13 -04:00
parent d699f492fa
commit f8ee7cc66e
6 changed files with 13 additions and 18 deletions

View File

@ -2,7 +2,7 @@
#include <stdlib.h> #include <stdlib.h>
uint64_t fnv1a_hash(char *key, size_t ln) { uint64_t fnv1a_hash(char* key, size_t ln) {
uint64_t hash = FNV1A_BASIS_64; uint64_t hash = FNV1A_BASIS_64;
for (size_t i = 0; i < ln; i++) { for (size_t i = 0; i < ln; i++) {

View File

@ -196,4 +196,3 @@ exp:
$$ = ast_init(AST_TYPE_CALL, ast_call_data_init(to, 2, argv)); $$ = ast_init(AST_TYPE_CALL, ast_call_data_init(to, 2, argv));
} }
%% %%

View File

@ -1,11 +1,10 @@
#include "include/htab.h" #include "include/htab.h"
#include "include/fnv1a.h" #include "include/fnv1a.h"
#include "include/util.h" #include "include/util.h"
#include "include/util.h"
#include <assert.h> #include <assert.h>
#include <string.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
HTab* htab_init() { HTab* htab_init() {
HTab* htab = calloc(1, sizeof(HTab)); HTab* htab = calloc(1, sizeof(HTab));
@ -13,9 +12,7 @@ HTab* htab_init() {
return htab; return htab;
} }
void htab_destroy(HTab *htab) { void htab_destroy(HTab* htab) { free(htab); }
free(htab);
}
// Get the index of a key. // Get the index of a key.
size_t geti(char* key) { size_t geti(char* key) {
@ -32,7 +29,7 @@ void* htab_get(HTab* htab, char* key) {
void htab_ins(HTab* htab, char* key, void* data) { void htab_ins(HTab* htab, char* key, void* data) {
size_t i = geti(key); size_t i = geti(key);
//assert((*htab)[i] == NULL); // assert((*htab)[i] == NULL);
(*htab)[i] = data; (*htab)[i] = data;
log_dbgf("Inserted something to hash table @ index %lu", i); log_dbgf("Inserted something to hash table @ index %lu", i);
} }

View File

@ -21,8 +21,6 @@ static AST* (*builtin_fns[NBUILTIN_FNS])(size_t argc, AST** argv) = {
builtin_sum, builtin_sub, builtin_mul, builtin_div builtin_sum, builtin_sub, builtin_mul, builtin_div
}; };
static char* builtin_fns_names[NBUILTIN_FNS] = { static char* builtin_fns_names[NBUILTIN_FNS] = {"sum", "sub", "mul", "div"};
"sum", "sub", "mul", "div"
};
#endif #endif

View File

@ -5,7 +5,8 @@
#include <stdint.h> #include <stdint.h>
#define HTAB_FN fnv1a_hash // Function used for hashing. #define HTAB_FN fnv1a_hash // Function used for hashing.
#define HTAB_SPACE 1024 // Number of entries possible in the hash table; must be #define HTAB_SPACE \
1024 // Number of entries possible in the hash table; must be
// power of 2. // power of 2.
// Hash Table. // Hash Table.