will need the clockwise spiral rule to parse this: http://c-faq.com/decl/spiral.anderson.html
http://webcache.googleusercontent.com/search?q=cache:V51nbJE...
(Cache link since original post is 500.)
51–60 of 104 posts
will need the clockwise spiral rule to parse this: http://c-faq.com/decl/spiral.anderson.html
http://webcache.googleusercontent.com/search?q=cache:V51nbJE...
(Cache link since original post is 500.)
This code reminds me why clever is the enemy of good.
Earlier quoted context omitted.
Technically there is bounds checking ... & (SIZE - 1) but it looks broken because t does the C-ish mutating accumulator thing rather than acting as a base and using h as an offset You need a temporary variable of int (**)[2] to avoid doing two additions per iter, though maybe the compiler can pick that up and do it for you. Anyway, this no longer crashes but it now runs forever if the hash fills https://gist.github.c…
>Due to C there is no way to declare both an int and that in the loop preamble so you'd need at least one more line In C99 it's allowed to declare in the loop preamble. True for ANSI-C.
Earlier quoted context omitted.
It's not hard to fix, however - one extra modulus, as far as I can see.
Technically there is bounds checking ... & (SIZE - 1) but it looks broken because t does the C-ish mutating accumulator thing rather than acting as a base and using h as an offset You need a temporary variable of int (**)[2] to avoid doing two additions per iter, though maybe the compiler can pick that up and do it for you. Anyway, this no longer crashes but it now runs forever if the hash fills https://gist.github.c…
Earlier quoted context omitted.
It's not hard to fix, however - one extra modulus, as far as I can see.
And an extra local variable. Which might take up a line of source code!
why would you a 2 element array of int here instead of defining a struct of 2 ints?
There's no bounds testing in hget(): some valid sequences of operations will cause buffer overflows. For example, this should segfault: int (**table)[2] = hnew(); for (int j=0; j The problem is, the probing function doesn't wrap (the "t += h" part), so if you have have several colliding keys, it will probe for them past the end of the table.
It wouldn't be C if that wasn't the case.