]> git.ipfire.org Git - thirdparty/squid.git/commit
MemPool the debug output stream buffers
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 19 Dec 2014 16:26:44 +0000 (08:26 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 19 Dec 2014 16:26:44 +0000 (08:26 -0800)
commitbfa0977917b3f2239615878e6e07e6e8eb0f9020
tree5bede14b60a3fbe6a45fe3f874049aa3d6550274
parentd54b51739879d5af9a909d682d44f3267bce002a
MemPool the debug output stream buffers

The CurrentDebug output stream controller for cache.log was
defined as a std::ostringstream object and allocated with
new/delete on each call to debugs().

The std::ostringstream is defined as a templates output stream
which uses the std::allocator<char> built into libc when its
new()'d. Since this is all internal to the STL library
definitions it links against the libc global-scope allocator.

However, there is no matching deallocator definition and when
the object is delete()'d the standard C++ operator overloading
rules make the global-scope SquidNew.h definition of
::operator delete() be the method of deallocation. That uses
free() internally.

To resolve the mismatch of new()/free() we must define a
wrapper class with explicit class-scope new/delete operators
instead of relying on weak linkages to overloaded global scope
operators.

As a result the memory is new()'d and free()'d. As detected by
Valgrind
src/Debug.h
src/debug.cc
src/tests/stub_debug.cc