Use calloc rather than malloc to avoid needing many memset calls.