removing use of alloca from grid.h