https://issues.dlang.org/show_bug.cgi?id=13159
Jakob Ovrum <jakobov...@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakobov...@gmail.com --- Comment #2 from Jakob Ovrum <jakobov...@gmail.com> --- I already posted a PR for this BTW: https://github.com/D-Programming-Language/phobos/pull/2351 (In reply to Orvid King from comment #1) > Assuming that infos has a length property, it would be better yet to simply > do: > > auto infos = getAddressInfo(hostname, service); > auto results = new Address[infos.length]; This would allocate even when infos.length is 0. > Which would result in exactly the amount of memory needed being allocated, > and only 1 allocation being done. `getAddressInfo` allocates too, and easily more than once, so that wouldn't be quite true. > I would also suggest the possibility of adding an OutputRange based version. We can do better - a version that returns the results as a lazy forward range. The most underlying data structure here is a singly linked list. We can use reference counting to ensure the list is freed (freeaddrinfo). It's a much heavier change though so I'm not going to do it in PR #2351. --