Fixed the allocate buffer problem

Uses calloc now for the buffer allocation