64-bit: fix a whole load of "error: cast from x to 'int' loses precision"

http://stackoverflow.com/questions/2024895/how-should-i-handle-cast-from-void-to-int-loses-precision-when-compiling

In 32bits, an int (which is a 32bit integer) will hold a pointer value.

When you move to 64bit, you can no longer store a pointer in an int - it isn't large enough to hold a 64bit pointer. The intptr_t type is designed for this.
Merge pull request #307 from archSeer/master

64-bit: fix a whole load of "error: cast from x to 'int' loses precision"