I'm passing uintptr_t that represents result of new SomeClass; between threads. For obtaining the object I use
void foo(uintptr_t n)
{
SomeClass *p = reinterpret_cast<SomeClass *>(n);
}
It works fine, but I can't think of a wat to to check if p is a valid object, as if somehow foo will be called with value that doesn't correspont to a memory address of my SomeClass object I will get invalid pointer.
As far as I know using void* also have this issue.
Aucun commentaire:
Enregistrer un commentaire