This is a best practices question. I am making an array
type * x = malloc(size*sizeof(type));
AFAIK sizeof gives a return value of size_t. Does that mean that I should use a size_t to declare, or pass around size? Also when indexing the array should I also use a size_t for the index variable? What is the best practice for these these? This is not something that they taught in school, and now that I'm getting into serious c++ I want to know.
Also if anyone has references of where I can find best practices for this kind of stuff it would be helpful? Kind of an etiquette for programmers book.
EDIT: The malloc should be cudaHostAlloc, or cudaMalloc, since I am developing a class that stores an array simultaneously on the device and host, and updates both at the same time. So malloc here is just a place holder for what I'll actually be doing.