Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hashmap implementation #46

Closed
wants to merge 4 commits into from
Closed

Hashmap implementation #46

wants to merge 4 commits into from

Conversation

NicoBliss
Copy link
Collaborator

should close issue #15

@NicoBliss NicoBliss linked an issue Jun 26, 2024 that may be closed by this pull request
Copy link
Contributor

@adamhutchings adamhutchings left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small-ish things:
For consistency, could we name the structs HashNode and HashMap
And could you add a test file for this?

But aside from that, looks good!

@NicoBliss NicoBliss requested a review from adamhutchings July 8, 2024 20:19
@NicoBliss
Copy link
Collaborator Author

Two small-ish things: For consistency, could we name the structs HashNode and HashMap And could you add a test file for this?

But aside from that, looks good!

All of this has been added (and a bunch of files header's lightly modified... sorry about that)

@JakeRoggenbuck
Copy link
Member

I get an error when building.

.../jccc/src/util/test_hash.c: In function ‘test_hashing’:
.../jccc/src/util/test_hash.c:25:24: error: initialization of ‘const char *’ from incompatible pointer type ‘char (*)[6]’ [-Wincompatible-pointer-types]
   25 |     const char *key1 = &string1;
      |                        ^
.../jccc/src/util/test_hash.c:26:24: error: initialization of ‘const char *’ from incompatible pointer type ‘char (*)[6]’ [-Wincompatible-pointer-types]
   26 |     const char *key2 = &string2;
      |                        ^

void *value = (void *)128;

hm_set(table, key, value);
tassert(hm_lookup(table, key) == (void *)128);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may also want to change this to something like

    tassert(*(int*)hm_lookup(table, key) == 128);

@JakeRoggenbuck
Copy link
Member

When I added test_minimal_case(); to test_hash

--- a/src/util/test_hash.c
+++ b/src/util/test_hash.c
@@ -10,6 +10,7 @@ int test_hash() {

     test_hashing();
     test_init_and_free();
+       test_minimal_case();
     test_100_inserts();
     test_100_removes();

When it's run, it segfaults,

Running "test_hashing"
Running "test_init_and_free"
Running "test_minimal_case"
Warning: jccc: hashmap full!
Segmentation fault (core dumped)

@adamhutchings
Copy link
Contributor

Closing due to inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hashmap
3 participants