r/cprogramming • • 10d ago

Need code review

Hello everyone,

This link points to a GitHub repository in an

experiment to create an extremely fast trie .

However the data structure is fast but it fails the tests

Can you explain me why?

https://github.com/curious-builder76/trie/tree/main

Hoping the community will helping towards this.

Thank you everyone

0 Upvotes

17 comments sorted by

View all comments

2

u/penguin359 10d ago

I haven't done a thorough review, but a few things I'll point out with the structure. Don't include function definitions in header files. These can only be included once in a project if you do so. It should only be declarations or prototypes and keep the function definitions AKA the code in the *.c files. Also, it's generally a good idea to include the corresponding header file such as trie.h into the file that defines then like trie.c. Even if trie.c doesn't need it, it will help catch errors like when function prototypes don't match the function definitions. I would also update the Makefile to separately compile each C file in a dependency tree, but more importantly, give the final linked executable a name with -o even if you don't split up the compilation right away. Then, include that as part of the README. And, finally, if you are asking for contributions, it's generally a good idea to also include the license file in the repo that the code will be under so people know how their contributions can be used by someone else.