D119177 broke some builds.
Let's fix up the header divergence and as algorithm> is a large header, this just open-codes the comparisons.
Also I took the chance to improve the hysteresis. If we needed more than double the buffer, the original code would allocate exactly the amount needed, and thus consequently the next request would also realloc. We're very unlikely to get into wanting more than double, after the first allocation, as it would require the user to have used an identifier larger than the hysteresis. With machine generated code that's possible, but unlikely.