cleanup: fix some memory leaks.  There's still something in getaddrinfo_a.

Also, setupterm leaks like a sieve.