Hacker News new | ask | show | jobs
by vukgr 1390 days ago
Can't say I've really thought this through, but couldn't you just subtract 1 (*sizeof(X)) from the arr address?
2 comments

What would memset(arr, 0, sizeof(arr)) do in that case? I can see myriad problems with having arr itself point outside the memory range allocated to arr[min..max].
Hmm, maybe?

You'd still have the odd subtract here or there, but for many use patterns you could probably ignore the overhead.