I have a program that read urls in a file and does a gethostbyname() on each URL host. This call is quite consuming. I want to cache them.
Is there a very simple map-base code snippet in C out there that I could use to do the caching? (I just don’t want to reinvent the wheel).
It has to have the following points :
- Open-source with a permissive license (think BSD or public domain).
- Very simple : ideally less than 100 LOC
- Keys are
char*and valuesvoid*. No need to copy them. - No real need to implement
remove(), butcontains()is either needed orput()should replace the value.
PS: I tagged it homework, since it could be. I’m just being very lazy and do want to avoid all the common pitfalls I could encounter while reimplementing.
Here’s a very simple and naive one
: