summaryrefslogtreecommitdiff
path: root/hash_tables.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2019-11-11 16:18:26 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2019-11-11 16:18:26 -0500
commit98fcdba9bf63ad79f40b832f3bff42f54aca6aab (patch)
tree1bf446829bcd78a8dfada37e104d062d0be32823 /hash_tables.c
parente800a25fd2c4945b465b4cd90b4d212272d1641c (diff)
declarations for functions with constant parameters
Diffstat (limited to 'hash_tables.c')
-rw-r--r--hash_tables.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/hash_tables.c b/hash_tables.c
index a8a5c82..e5f1652 100644
--- a/hash_tables.c
+++ b/hash_tables.c
@@ -60,6 +60,8 @@ static U64 f64_hash(F64 f) {
return hash;
}
+static void fprint_val(FILE *f, Value v, Type *t); /* DELME */
+static void fprint_type(FILE *out, Type *t); /* !! */
/* Note that for these value hashing functions, values of different types may collide */
static U64 val_ptr_hash(void *v, Type *t) {
switch (t->kind) {
@@ -223,8 +225,8 @@ static bool val_eq(Value u, Value v, Type *t) {
static bool val_hash_table_adda(Allocator *a, HashTable *h, Value v, Type *t, I64 *associated_number) {
if (h->n * 2 >= h->cap) {
U64 new_cap = h->cap * 2 + 2;
- ValNumPair *new_data = a ? allocr_malloc(a, new_cap * (U64)sizeof *new_data)
- : malloc(new_cap * sizeof *new_data);
+ ValNumPair *new_data = a ? allocr_malloc(a, (size_t)new_cap * sizeof *new_data)
+ : malloc((size_t)new_cap * sizeof *new_data);
bool *new_occupied = a ? allocr_calloc(a, (size_t)new_cap, sizeof *new_occupied)
: calloc((size_t)new_cap, sizeof *new_occupied);
ValNumPair *old_data = h->data;
@@ -281,6 +283,7 @@ static bool val_hash_table_add(HashTable *h, Value v, Type *t, I64 *associated_n
/* only call if you're not using an allocator */
static void hash_table_free(HashTable *h) {
free(h->data);
+ free(h->occupied);
}
static void val_hash_table_test(void) {