fixing cudafree and cudamalloc bugs