I have a C++ API with a C wrapper. A C client can get a handle to an underlying C++ object and then use that to get other information about the object, e.g.
PersonHandle handle = createPerson("NisseIHult");
char* name = getPersonName(handle); //Get person takes a void* pointer
In the code above, the handle is casted to a C++ Person class object.
Question is, how can I check inside getPersonName that the argument, handle, is a valid handle? For example, if a client does this:
char* name = getPersonName(1234);
it will cause an access violation inside getPersonName. I need a way to check and validate the handle, and in the case above, return NULL?