Fixed a crash with GCC libs caused by calling FreeHGlobal on non-AllocHGlobal memory.

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
Wrapped void* as IntPtr because unlike int*, char*, etc., void* is just ugly and not useful.

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>