copy C array of structs to GPU with driver API and use it device memory management

I have a C struct array. I use the Driver API. Can I copy this with something like the following?

[codebox]CUdeviceptr d_pMyStructArray;

cuMemAlloc(d_pMyStructArray, n * sizeof(MyStruct));

cuMemcpyHToD(d_pMyStructArray, h_pMyStructArray, n* sizeof(MyStruct))[/codebox]

And then how do I pass the pointer to the kernel? Like this?

[codebox]int offset = 0;

void *ptr;

ptr = (void*)(size_t) d_pMyStructArray;

ALIGN_UP(offset, __alignof(ptr);

cuParamSetv(myCUDAFun, offset, &ptr, sizeof(ptr));

offset += sizeof(ptr);

cuParamSetSize(myCUDAFun, offset);

ALIGN_UP(offset, __alignof(N);

cuParamSeti(vecAdd, offset, N);

offset += sizeof(N);[/codebox]