Plug leaks and fix a C99-ism

We have too many places where we repeat free code, so when adding the
new free to the generic code, it didn't take for the local transport.

While there, fix a C99-ism that sneaked through.