What's void *userData exactly?
- by mystify
In a C function declaration, I have seen this parameter definition:
void *userData
so, what exactly is that? My guess: the void says it can be anything arbitrary, or even nothing. Almost similar to id of objective-c. It just allows to pass in whatever data structure you like.
The star in front of userData says, that the argument must be passed in by reference.
So when using this stuff in the function body, typically it must be casted and dereferenced.
So if I pass in an pointer to SomeClass instance, I would get that like this:
SomeClass *myObj = (SomeClass*)userData;
In the case I had nothing special to pass along, I would provide NULL as argument.
Are my assumptions correct? Or did I get something wrong?