Substantial parts of the memstream and wmemstream implementations
overlap, and it's a little laborious to duplicate code between the two.
Abstract the differences out into some streamcfg structs and see if we
can get the arithmetic right and converge on a single implementation.