Memory locality
techtalk.intersec.com
techtalk.intersec.com
int get_at(const struct foo_t *foo, int pos) { return foo->len >= pos ? -1 : foo->data[pos]; }
!(foo->len >= pos) = (pos >= foo->len) => foo->data[pos] = foo->data[foo->len + x] where x >= 0, which is undefined.
It seems the author got caught up trying to be tricky, and the fix has the bonus of reading more naturally:
return (pos < foo->len) ? foo->data[pos] : -1;
It is late though. Maybe my brain isn't in gear...