fix the calloc reset memory when out of memory problem