Locks-and-keys (computing)

Locks-and-keys is a solution to dangling pointers in computer programming languages.

The locks-and-keys approach represents pointers as ordered pairs (key, address) where the key is an integer value.

When a variable is allocated, a lock value is created and placed both into the variable's cell and into the pointer's key cell.

When a variable is deallocated, the key of its pointer is modified to hold a value different from the variable's cell.

From then on, any attempt to dereference the pointer can be flagged as an error.