switch to calloc from malloc/memset and check return