Added DESTDIR compatibility for netcdf builds that generate a dll via autotools.
Fixed several memory leaks reported by static analysis.