invalid device pointer freeing something I just made

I’m getting this strange problem with this code

cudaPitchedPtr d_result;

  cudaExtent extent = make_cudaExtent(4, 4, 4);

  cutilSafeCall(cudaMalloc3D(&d_result, extent));

  cutilSafeCall(cudaFree(&d_result));   //FAILS with invalid device pointer

  exit(1);

what the hell is going on? is this a vista bug?

nevermind. I didn’t know you had to use the ptr inside the struct

which means in clear you have to write :

cutilSafeCall(cudaFree(d_result.ptr));

It would be nice to have a word about that in the documentation…