latest non functioning hasmap

This commit is contained in:
Ivar Fatland
2026-05-10 00:16:02 +02:00
parent 1c19b4435c
commit 2fd707741b
2 changed files with 8 additions and 4 deletions
+6 -3
View File
@@ -1,4 +1,4 @@
CC := "cc"
CC := "zig cc"
CFLAGS := "-pedantic -Wall -Wextra -Wno-override-init -O0 -g -fno-omit-frame-pointer -fno-inline"
LDFLAGS := if os() == "macos" {
"$(pkg-config --libs --cflags criterion)"
@@ -18,11 +18,14 @@ FOOBAR_SOURCE := FOOBAR+".c"
FOOBAR_BIN := TMP/FOOBAR
FOOBAR_EXPANDED := TMP/FOOBAR+"-expanded.c"
build_foobar2:
{{CC}} {{FOOBAR_SOURCE}} {{CFLAGS}} -o foobar2
run_foobar: build_foobar
./{{FOOBAR_BIN}}
{{FOOBAR_BIN}}
build_foobar: foobar_expanded
{{CC}} {{FOOBAR_EXPANDED}} -o {{FOOBAR_BIN}} {{CFLAGS}}
{{CC}} {{FOOBAR_EXPANDED}} {{CFLAGS}} -o {{FOOBAR_BIN}}
echo "{{FOOBAR_BIN}}"
foobar_expanded:
+2 -1
View File
@@ -179,6 +179,7 @@ index_pair_t map_pair_hash(void *this, void *pair) {
mapping_index = (mapping_index + 1) % header->mapping_capacity;
existing_value_index = header->mapping_arr[mapping_index];
}
// TODO FUCKING IDIOT! has_old_index is set to true for NO REASON. Why???
// Whatever is at index is either free, or the key is already in the map.
//
@@ -234,7 +235,7 @@ void map_assure_growable_by_1(void **this, const char *file, int line) {
// The reason for re-hashing is that all hashes are moduloed by the
// size of the mapping array, so the resulting hash will likely change.
for ( unsigned int i = 0; i < header->n_items; i++ ) {
void *pair = &((uint8_t *)(*this))[i*header->item_size];
void *pair = &(((uint8_t *)(*this))[i*header->item_size]);
// This is okay, because we absolutely know that the keys don't already
// exist. (assuming all the other code for map is doing it's job)