Commit 34524286 authored by evan@chromium.org's avatar evan@chromium.org

Remove the free_ member of scoped_ptr_malloc.

Conceptually, the function to call is known at compile time.
There is no reason to save it into a static variable.  It turns out
doing causes the compiler to emit a static initializer to track whether
free_ has been initialized.

This change removes static initializers from eight .o files on my local
Release build.

BUG=87171

Review URL: http://codereview.chromium.org/7795008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98718 0039d316-1c4b-4281-b951-d872f2087c98
parent 09c4fc35
......@@ -285,7 +285,7 @@ class scoped_ptr_malloc {
// Destructor. If there is a C object, call the Free functor.
~scoped_ptr_malloc() {
free_(ptr_);
reset();
}
// Reset. Calls the Free functor on the current owned object, if any.
......@@ -293,7 +293,8 @@ class scoped_ptr_malloc {
// this->reset(this->get()) works.
void reset(C* p = NULL) {
if (ptr_ != p) {
free_(ptr_);
FreeProc free_proc;
free_proc(ptr_);
ptr_ = p;
}
}
......@@ -355,16 +356,11 @@ class scoped_ptr_malloc {
template <class C2, class GP>
bool operator!=(scoped_ptr_malloc<C2, GP> const& p) const;
static FreeProc const free_;
// Disallow evil constructors
scoped_ptr_malloc(const scoped_ptr_malloc&);
void operator=(const scoped_ptr_malloc&);
};
template<class C, class FP>
FP const scoped_ptr_malloc<C, FP>::free_ = FP();
template<class C, class FP> inline
void swap(scoped_ptr_malloc<C, FP>& a, scoped_ptr_malloc<C, FP>& b) {
a.swap(b);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment