dynamic allocator (suggested by @timboudreau)