Earlier quoted context omitted.
Not differing types
If you really want to, I think you might be able to declare a struct in there. A curse on your house though....
15-line hash table in C
101–104 of 104 posts
Re: 15-line hash table in C
#102Earlier quoted context omitted.
Note that on many systems (e.g. Linux), malloc/calloc won't always return NULL when you're out of memory because of lazy memory allocation policies. It will only crash when you start reading / writing. That makes it arguably less useful to test the return value. edit: clarity.
However, mmap and the functions which rely on it will return MAP_FAILED/NULL if no gap large enough is found in the virtual address space or if you've used MAP_FIXED and the area isn't free. If you don't check for errors, the application could potentially end up trying to dereference a NULL pointer.
That's what I wanted to point, and I agree that it remains useful to detect other types of errors such as the ones you mentioned.
Re: 15-line hash table in C
#103Also, sizeof(int star-star) in hnew should be sizeof( int (star)[2] ).