Get the latest tech news

Using uninitialized memory for fun and profit (2008)


, March 14, 2008. This is the story of a clever trick that's been around for at least 35 years, in which array values can be left uninitialized and then read during normal operations, yet the code behaves correctly no matter what garbage is sitting in the array.

The sleaziness of uninitialized data access is offset by performance improvements: some important operations change from linear to constant time. To make it fast, Briggs and Torczon add a second array named sparse which maps integers to their indices in dense. Returning to the original exercises, it is trivial to change the set into a vector (or matrix) by making dense an array of index-value pairs instead of just indices.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Fun

Fun

Photo of profit

profit

Photo of uninitialized memory

uninitialized memory

Related news:

News photo

Dina Titus pokes fun at prediction markets in wake of FAIR BET ACT progress

News photo

Fun with gzip bombs and email clients

News photo

Ubisoft reckons microtransactions help make games "more fun", but still wants to ensure they "respect the player experience"