Casting void* to relevant pointer type