Bz/fix freebsd

Fix issues. Tested with freeBSD 9.2 and 10.
I don't see anything in the man page that confirms that it is not allocated when there is an error. Given this, I think we should call `freeaddrinfo(address)` if `addresses` is not null.