[trunk] allow compilation with MinGW32 (fixes issue 361)
[trunk] improve memory management (fixes issue 359)