Follow-up for abe72100cf.
abe72100cf
There is many pitfalls in using memstream. Let's introduce a wrapper to make us safely use it.