oops, corrupted memory again!

Ray Butterworth rbutterworth at watmath.UUCP
Fri May 2 01:53:40 AEST 1986


>    You're probably better off with a language that compiles checks into
> the code, and an option to turn off those checks once you're confident
> (?!) of the program.  With a capability-based architecture, you pay the
> price all the time, whether you want to or not.

Many years ago I worked with a language in which all arrays had to
have dimensions that were a power of two (like 4.2 malloc).  The
code which indexed into the array simply anded the index with the
appropriate bit mask.  This was very fast, yet it guaranteed that
any bad indexes wouldn't corrupt anything except the array being
addressed.  As a side-effect, one could use this feature to cycle
continuously through an array or could even use negative indexes
without any extra overhead.



More information about the Comp.lang.c mailing list