To freeze the allocation of strstreambuf.
void freeze(bool freezefl = true);
The function freeze() stops allocation if the strstreambuf object is using dynamic allocation and prevents the destructor from freeing the allocation.
The function freeze(false) releases the freeze to allow for destruction.
There is no return.
#include <iostream> #include <strstream> #include <string.h> const int size = 100; int main() { // dynamic allocation minimum allocation 100 strstreambuf strbuf(size); // add a string and get size strbuf.sputn( "CodeWarrior", strlen("CodeWarrior")); cout << "The size of the stream is: " << strbuf.pcount() << endl; strbuf.sputc('\0'); // null terminate for output // now freeze for no more growth strbuf.freeze(); // try to add more strbuf.sputn( " -- Software at Work --", strlen(" -- Software at Work --")); cout << "The size of the stream is: " << strbuf.pcount() << endl; cout << "The buffer contains:\n" << strbuf.str() << endl; return 0; }