dotcloud/docker — pull request #272 by dominikh (2013-03-30 22:38:41+00:00)
Title: Make IP allocator lazy

Instead of allocating all possible IPs in advance, generate them as
needed. Released IPs will not be fed back to the channel but stored in
a linked list. Said linked list will be used once the initial
generator exhausted all possible IPs.

In the worst case (VMs using up the entire /8 space, then releasing
the entire /8 space), memory usage will be slightly higher than
before (overhead of the list). In the usual case (an equal amount of
VMs acquiring and releasing IPs), memory usage will be relatively
constant. In both cases, IPs that have never been acquired will not
occupy memory.

Due to required API changes (the IP allocator runs in a goroutine now
and thus cannot easily return errors), the functions that are
responsible for IP/Mask<->int conversions have been rewritten to be
error-free.

Fixes gh-231