Comment by HarHarVeryFunny

3 hours ago

It's extremely inefficient, using pointers to neighboring cells.

If you want to handle the grid edges (whether for a wrap-around "infinite" grid, or not) without too much special code, then leave a 1-cell border around the grid and fill this with the appropriate data (empty cells, or wraparound cells). If you really want to be efficient then just write the special-case edge code.