|
|
|
|
|
by clarry
3224 days ago
|
|
Don't allocate these items individually; don't store pointers to such items. They're tiny, and the pointer chasing + allocator bookkeeping overhead + potential randomisation make it inefficient for no gain. Just allocate an array of items. This way you'll also deal with fewer potential errors. Speaking of errors, please handle them and fix the API so that the caller can know if there's a problem. |
|
Also the use of strdup, while a reasonable choice, should also come with caveats about ownership and copying
I stopped at the use of pow for exponentiation in the hash function. Just iteratively multiply your factor and take the modulus on each round.
This would handle utf-8 just fine if characters are cast to unsigned in the hash function and a larger prime factor is used
None of these are real criticisms, I'd just love to see a pointer to more in depth information on how to really write hash functions
I hope that i missed it, but this definitely needs a clear statement that this is a pedagogical exercise and not a production ready implementation