fixed off by one error and properly accounted for pointer reinitialization on realloc in cstrtodstr