Jump to content

Creating a Hash Table in C.

Gat Pelsinger

I am working upon a Hash Table in C and I will post my code for review shortly, but before that I running into one problem. An easy way is to pre-allocate the whole table, but I want to be memory efficient and only allocate the indexes of the table which are needed. But the problem is, my hash function returns a value which will be used as an index of the table where the key/value pair will be allocated, but if I haven't malloced my table yet, I can't do pointer arithmetic and jump to an index of the table and allocate there. I haven't owned the contiguous memory yet. So one way would be to map the next free index of the table to the hash value I have received from my hash function. I cannot call my own functions as that would just result in infinite recursion and stack overflow, and I really don't want to create another sub hash table inside my function, its gonna be very messy.

Microsoft owns my soul.

 

Also, Dell is evil, but HP kinda nice.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×