Initial version of memory pool logic. Needs unit tests. Made to be easily separable from Tor. svn:r9937