Added check for calloc() failure