Added intermediate casts to void* to prevent spurious warnings (with Clang and -Wcast-align).
Initial import.