Add safe_malloc that simply terminates if out of memory