Cast to a pointer instead of long to avoid crashes on x64 builds

Based on TortoiseSVN revision 25008

Signed-off-by: Sup Yut Sum <ch3cooli@gmail.com>
Free allocated memory

Based on TortoiseSVN revision 25004

Signed-off-by: Sup Yut Sum <ch3cooli@gmail.com>
Initialize member variables

Based on TortoiseSVN revision 25001

Signed-off-by: Sup Yut Sum <ch3cooli@gmail.com>