It's really uncommon in PCL and in general to return a pointer to heap memory in C++. Please use a PointCloud, as done in the RangeImage.