From 63c5d980030fde07558ce006c1710cb64fff7986 Mon Sep 17 00:00:00 2001 From: "ted.mielczarek@gmail.com" Date: Thu, 17 Jan 2013 15:53:56 +0000 Subject: Move scoped_ptr.h to common R=mark at https://breakpad.appspot.com/509002/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1096 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/processor/basic_source_line_resolver_types.h | 2 +- .../basic_source_line_resolver_unittest.cc | 2 +- src/processor/cfi_frame_info.cc | 2 +- src/processor/exploitability.cc | 2 +- src/processor/exploitability_win.cc | 2 +- src/processor/fast_source_line_resolver.cc | 2 +- src/processor/minidump.cc | 3 +- src/processor/minidump_dump.cc | 2 +- src/processor/minidump_processor.cc | 2 +- src/processor/minidump_processor_unittest.cc | 2 +- src/processor/minidump_stackwalk.cc | 2 +- src/processor/module_comparer.cc | 2 +- src/processor/range_map_unittest.cc | 3 +- src/processor/scoped_ptr.h | 335 --------------------- src/processor/stack_frame_symbolizer.cc | 2 +- src/processor/stackwalker.cc | 2 +- src/processor/stackwalker_amd64.cc | 2 +- src/processor/stackwalker_arm.cc | 2 +- src/processor/stackwalker_selftest.cc | 2 +- src/processor/stackwalker_x86.cc | 2 +- .../static_contained_range_map_unittest.cc | 3 +- src/processor/static_range_map_unittest.cc | 4 +- 22 files changed, 23 insertions(+), 359 deletions(-) delete mode 100644 src/processor/scoped_ptr.h (limited to 'src/processor') diff --git a/src/processor/basic_source_line_resolver_types.h b/src/processor/basic_source_line_resolver_types.h index 87b93db9..94616dcb 100644 --- a/src/processor/basic_source_line_resolver_types.h +++ b/src/processor/basic_source_line_resolver_types.h @@ -40,6 +40,7 @@ #include #include +#include "common/scoped_ptr.h" #include "google_breakpad/processor/basic_source_line_resolver.h" #include "processor/source_line_resolver_base_types.h" @@ -48,7 +49,6 @@ #include "processor/contained_range_map-inl.h" #include "processor/linked_ptr.h" -#include "processor/scoped_ptr.h" #include "google_breakpad/processor/stack_frame.h" #include "processor/cfi_frame_info.h" #include "processor/windows_frame_info.h" diff --git a/src/processor/basic_source_line_resolver_unittest.cc b/src/processor/basic_source_line_resolver_unittest.cc index bf8507ae..6e3c164c 100644 --- a/src/processor/basic_source_line_resolver_unittest.cc +++ b/src/processor/basic_source_line_resolver_unittest.cc @@ -32,6 +32,7 @@ #include #include "breakpad_googletest_includes.h" +#include "common/scoped_ptr.h" #include "common/using_std_string.h" #include "google_breakpad/processor/basic_source_line_resolver.h" #include "google_breakpad/processor/code_module.h" @@ -39,7 +40,6 @@ #include "google_breakpad/processor/memory_region.h" #include "processor/linked_ptr.h" #include "processor/logging.h" -#include "processor/scoped_ptr.h" #include "processor/windows_frame_info.h" #include "processor/cfi_frame_info.h" diff --git a/src/processor/cfi_frame_info.cc b/src/processor/cfi_frame_info.cc index 1ded99d3..d8394619 100644 --- a/src/processor/cfi_frame_info.cc +++ b/src/processor/cfi_frame_info.cc @@ -38,8 +38,8 @@ #include +#include "common/scoped_ptr.h" #include "processor/postfix_evaluator-inl.h" -#include "processor/scoped_ptr.h" namespace google_breakpad { diff --git a/src/processor/exploitability.cc b/src/processor/exploitability.cc index 459e7ce1..16807a3c 100644 --- a/src/processor/exploitability.cc +++ b/src/processor/exploitability.cc @@ -36,12 +36,12 @@ #include +#include "common/scoped_ptr.h" #include "google_breakpad/processor/exploitability.h" #include "google_breakpad/processor/minidump.h" #include "google_breakpad/processor/process_state.h" #include "processor/exploitability_win.h" #include "processor/logging.h" -#include "processor/scoped_ptr.h" namespace google_breakpad { diff --git a/src/processor/exploitability_win.cc b/src/processor/exploitability_win.cc index 443635fb..e0798452 100644 --- a/src/processor/exploitability_win.cc +++ b/src/processor/exploitability_win.cc @@ -38,11 +38,11 @@ #include "processor/exploitability_win.h" +#include "common/scoped_ptr.h" #include "google_breakpad/common/minidump_exception_win32.h" #include "google_breakpad/processor/minidump.h" #include "processor/disassembler_x86.h" #include "processor/logging.h" -#include "processor/scoped_ptr.h" #include "third_party/libdisasm/libdis.h" diff --git a/src/processor/fast_source_line_resolver.cc b/src/processor/fast_source_line_resolver.cc index a7b99331..29a8f091 100644 --- a/src/processor/fast_source_line_resolver.cc +++ b/src/processor/fast_source_line_resolver.cc @@ -44,9 +44,9 @@ #include #include +#include "common/scoped_ptr.h" #include "common/using_std_string.h" #include "processor/module_factory.h" -#include "processor/scoped_ptr.h" using std::map; using std::make_pair; diff --git a/src/processor/minidump.cc b/src/processor/minidump.cc index 0bd1f6ba..d033a0b6 100644 --- a/src/processor/minidump.cc +++ b/src/processor/minidump.cc @@ -60,10 +60,11 @@ typedef SSIZE_T ssize_t; #include "processor/range_map-inl.h" +#include "common/scoped_ptr.h" #include "processor/basic_code_module.h" #include "processor/basic_code_modules.h" #include "processor/logging.h" -#include "processor/scoped_ptr.h" + namespace google_breakpad { diff --git a/src/processor/minidump_dump.cc b/src/processor/minidump_dump.cc index 869a7632..f14aee85 100644 --- a/src/processor/minidump_dump.cc +++ b/src/processor/minidump_dump.cc @@ -35,9 +35,9 @@ #include #include +#include "common/scoped_ptr.h" #include "google_breakpad/processor/minidump.h" #include "processor/logging.h" -#include "processor/scoped_ptr.h" namespace { diff --git a/src/processor/minidump_processor.cc b/src/processor/minidump_processor.cc index db5b271a..14615ee9 100644 --- a/src/processor/minidump_processor.cc +++ b/src/processor/minidump_processor.cc @@ -32,13 +32,13 @@ #include #include +#include "common/scoped_ptr.h" #include "google_breakpad/processor/call_stack.h" #include "google_breakpad/processor/minidump.h" #include "google_breakpad/processor/process_state.h" #include "google_breakpad/processor/exploitability.h" #include "google_breakpad/processor/stack_frame_symbolizer.h" #include "processor/logging.h" -#include "processor/scoped_ptr.h" #include "processor/stackwalker_x86.h" namespace google_breakpad { diff --git a/src/processor/minidump_processor_unittest.cc b/src/processor/minidump_processor_unittest.cc index 917caaf4..999637d3 100644 --- a/src/processor/minidump_processor_unittest.cc +++ b/src/processor/minidump_processor_unittest.cc @@ -39,6 +39,7 @@ #include #include "breakpad_googletest_includes.h" +#include "common/scoped_ptr.h" #include "common/using_std_string.h" #include "google_breakpad/processor/basic_source_line_resolver.h" #include "google_breakpad/processor/call_stack.h" @@ -50,7 +51,6 @@ #include "google_breakpad/processor/stack_frame.h" #include "google_breakpad/processor/symbol_supplier.h" #include "processor/logging.h" -#include "processor/scoped_ptr.h" #include "processor/stackwalker_unittest_utils.h" using std::map; diff --git a/src/processor/minidump_stackwalk.cc b/src/processor/minidump_stackwalk.cc index b3137d97..7218fd88 100644 --- a/src/processor/minidump_stackwalk.cc +++ b/src/processor/minidump_stackwalk.cc @@ -39,6 +39,7 @@ #include #include +#include "common/scoped_ptr.h" #include "common/using_std_string.h" #include "google_breakpad/processor/basic_source_line_resolver.h" #include "google_breakpad/processor/call_stack.h" @@ -50,7 +51,6 @@ #include "google_breakpad/processor/stack_frame_cpu.h" #include "processor/logging.h" #include "processor/pathname_stripper.h" -#include "processor/scoped_ptr.h" #include "processor/simple_symbol_supplier.h" namespace { diff --git a/src/processor/module_comparer.cc b/src/processor/module_comparer.cc index 09b85e03..ba561eea 100644 --- a/src/processor/module_comparer.cc +++ b/src/processor/module_comparer.cc @@ -37,9 +37,9 @@ #include #include +#include "common/scoped_ptr.h" #include "processor/basic_code_module.h" #include "processor/logging.h" -#include "processor/scoped_ptr.h" #define ASSERT_TRUE(condition) \ if (!(condition)) { \ diff --git a/src/processor/range_map_unittest.cc b/src/processor/range_map_unittest.cc index 996ae6d7..bf9b7279 100644 --- a/src/processor/range_map_unittest.cc +++ b/src/processor/range_map_unittest.cc @@ -37,10 +37,9 @@ #include "processor/range_map-inl.h" +#include "common/scoped_ptr.h" #include "processor/linked_ptr.h" #include "processor/logging.h" -#include "processor/scoped_ptr.h" - namespace { diff --git a/src/processor/scoped_ptr.h b/src/processor/scoped_ptr.h deleted file mode 100644 index 0d4f7fd3..00000000 --- a/src/processor/scoped_ptr.h +++ /dev/null @@ -1,335 +0,0 @@ -// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999. -// Copyright (c) 2001, 2002 Peter Dimov -// -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// -// See http://www.boost.org/libs/smart_ptr/scoped_ptr.htm for documentation. -// - -// scoped_ptr mimics a built-in pointer except that it guarantees deletion -// of the object pointed to, either on destruction of the scoped_ptr or via -// an explicit reset(). scoped_ptr is a simple solution for simple needs; -// use shared_ptr or std::auto_ptr if your needs are more complex. - -// *** NOTE *** -// If your scoped_ptr is a class member of class FOO pointing to a -// forward declared type BAR (as shown below), then you MUST use a non-inlined -// version of the destructor. The destructor of a scoped_ptr (called from -// FOO's destructor) must have a complete definition of BAR in order to -// destroy it. Example: -// -// -- foo.h -- -// class BAR; -// -// class FOO { -// public: -// FOO(); -// ~FOO(); // Required for sources that instantiate class FOO to compile! -// -// private: -// scoped_ptr bar_; -// }; -// -// -- foo.cc -- -// #include "foo.h" -// FOO::~FOO() {} // Empty, but must be non-inlined to FOO's class definition. - -// scoped_ptr_malloc added by Google -// When one of these goes out of scope, instead of doing a delete or -// delete[], it calls free(). scoped_ptr_malloc is likely to see -// much more use than any other specializations. - -// release() added by Google -// Use this to conditionally transfer ownership of a heap-allocated object -// to the caller, usually on method success. - -#ifndef PROCESSOR_SCOPED_PTR_H__ -#define PROCESSOR_SCOPED_PTR_H__ - -#include // for std::ptrdiff_t -#include // for assert -#include // for free() decl - -namespace google_breakpad { - -template -class scoped_ptr { - private: - - T* ptr; - - scoped_ptr(scoped_ptr const &); - scoped_ptr & operator=(scoped_ptr const &); - - public: - - typedef T element_type; - - explicit scoped_ptr(T* p = 0): ptr(p) {} - - ~scoped_ptr() { - typedef char type_must_be_complete[sizeof(T)]; - delete ptr; - } - - void reset(T* p = 0) { - typedef char type_must_be_complete[sizeof(T)]; - - if (ptr != p) { - delete ptr; - ptr = p; - } - } - - T& operator*() const { - assert(ptr != 0); - return *ptr; - } - - T* operator->() const { - assert(ptr != 0); - return ptr; - } - - bool operator==(T* p) const { - return ptr == p; - } - - bool operator!=(T* p) const { - return ptr != p; - } - - T* get() const { - return ptr; - } - - void swap(scoped_ptr & b) { - T* tmp = b.ptr; - b.ptr = ptr; - ptr = tmp; - } - - T* release() { - T* tmp = ptr; - ptr = 0; - return tmp; - } - - private: - - // no reason to use these: each scoped_ptr should have its own object - template bool operator==(scoped_ptr const& p) const; - template bool operator!=(scoped_ptr const& p) const; -}; - -template inline -void swap(scoped_ptr& a, scoped_ptr& b) { - a.swap(b); -} - -template inline -bool operator==(T* p, const scoped_ptr& b) { - return p == b.get(); -} - -template inline -bool operator!=(T* p, const scoped_ptr& b) { - return p != b.get(); -} - -// scoped_array extends scoped_ptr to arrays. Deletion of the array pointed to -// is guaranteed, either on destruction of the scoped_array or via an explicit -// reset(). Use shared_array or std::vector if your needs are more complex. - -template -class scoped_array { - private: - - T* ptr; - - scoped_array(scoped_array const &); - scoped_array & operator=(scoped_array const &); - - public: - - typedef T element_type; - - explicit scoped_array(T* p = 0) : ptr(p) {} - - ~scoped_array() { - typedef char type_must_be_complete[sizeof(T)]; - delete[] ptr; - } - - void reset(T* p = 0) { - typedef char type_must_be_complete[sizeof(T)]; - - if (ptr != p) { - delete [] ptr; - ptr = p; - } - } - - T& operator[](std::ptrdiff_t i) const { - assert(ptr != 0); - assert(i >= 0); - return ptr[i]; - } - - bool operator==(T* p) const { - return ptr == p; - } - - bool operator!=(T* p) const { - return ptr != p; - } - - T* get() const { - return ptr; - } - - void swap(scoped_array & b) { - T* tmp = b.ptr; - b.ptr = ptr; - ptr = tmp; - } - - T* release() { - T* tmp = ptr; - ptr = 0; - return tmp; - } - - private: - - // no reason to use these: each scoped_array should have its own object - template bool operator==(scoped_array const& p) const; - template bool operator!=(scoped_array const& p) const; -}; - -template inline -void swap(scoped_array& a, scoped_array& b) { - a.swap(b); -} - -template inline -bool operator==(T* p, const scoped_array& b) { - return p == b.get(); -} - -template inline -bool operator!=(T* p, const scoped_array& b) { - return p != b.get(); -} - - -// This class wraps the c library function free() in a class that can be -// passed as a template argument to scoped_ptr_malloc below. -class ScopedPtrMallocFree { - public: - inline void operator()(void* x) const { - free(x); - } -}; - -// scoped_ptr_malloc<> is similar to scoped_ptr<>, but it accepts a -// second template argument, the functor used to free the object. - -template -class scoped_ptr_malloc { - private: - - T* ptr; - - scoped_ptr_malloc(scoped_ptr_malloc const &); - scoped_ptr_malloc & operator=(scoped_ptr_malloc const &); - - public: - - typedef T element_type; - - explicit scoped_ptr_malloc(T* p = 0): ptr(p) {} - - ~scoped_ptr_malloc() { - typedef char type_must_be_complete[sizeof(T)]; - free_((void*) ptr); - } - - void reset(T* p = 0) { - typedef char type_must_be_complete[sizeof(T)]; - - if (ptr != p) { - free_((void*) ptr); - ptr = p; - } - } - - T& operator*() const { - assert(ptr != 0); - return *ptr; - } - - T* operator->() const { - assert(ptr != 0); - return ptr; - } - - bool operator==(T* p) const { - return ptr == p; - } - - bool operator!=(T* p) const { - return ptr != p; - } - - T* get() const { - return ptr; - } - - void swap(scoped_ptr_malloc & b) { - T* tmp = b.ptr; - b.ptr = ptr; - ptr = tmp; - } - - T* release() { - T* tmp = ptr; - ptr = 0; - return tmp; - } - - private: - - // no reason to use these: each scoped_ptr_malloc should have its own object - template - bool operator==(scoped_ptr_malloc const& p) const; - template - bool operator!=(scoped_ptr_malloc const& p) const; - - static FreeProc const free_; -}; - -template -FP const scoped_ptr_malloc::free_ = FP(); - -template inline -void swap(scoped_ptr_malloc& a, scoped_ptr_malloc& b) { - a.swap(b); -} - -template inline -bool operator==(T* p, const scoped_ptr_malloc& b) { - return p == b.get(); -} - -template inline -bool operator!=(T* p, const scoped_ptr_malloc& b) { - return p != b.get(); -} - -} // namespace google_breakpad - -#endif // PROCESSOR_SCOPED_PTR_H__ diff --git a/src/processor/stack_frame_symbolizer.cc b/src/processor/stack_frame_symbolizer.cc index e12fccbc..5d95abbf 100644 --- a/src/processor/stack_frame_symbolizer.cc +++ b/src/processor/stack_frame_symbolizer.cc @@ -36,6 +36,7 @@ #include +#include "common/scoped_ptr.h" #include "google_breakpad/processor/code_module.h" #include "google_breakpad/processor/code_modules.h" #include "google_breakpad/processor/source_line_resolver_interface.h" @@ -44,7 +45,6 @@ #include "google_breakpad/processor/system_info.h" #include "processor/linked_ptr.h" #include "processor/logging.h" -#include "processor/scoped_ptr.h" namespace google_breakpad { diff --git a/src/processor/stackwalker.cc b/src/processor/stackwalker.cc index 16880441..37664d41 100644 --- a/src/processor/stackwalker.cc +++ b/src/processor/stackwalker.cc @@ -37,6 +37,7 @@ #include +#include "common/scoped_ptr.h" #include "google_breakpad/processor/call_stack.h" #include "google_breakpad/processor/code_module.h" #include "google_breakpad/processor/code_modules.h" @@ -46,7 +47,6 @@ #include "google_breakpad/processor/system_info.h" #include "processor/linked_ptr.h" #include "processor/logging.h" -#include "processor/scoped_ptr.h" #include "processor/stackwalker_ppc.h" #include "processor/stackwalker_sparc.h" #include "processor/stackwalker_x86.h" diff --git a/src/processor/stackwalker_amd64.cc b/src/processor/stackwalker_amd64.cc index b7d3274d..0fec3d71 100644 --- a/src/processor/stackwalker_amd64.cc +++ b/src/processor/stackwalker_amd64.cc @@ -34,13 +34,13 @@ // Author: Mark Mentovai, Ted Mielczarek +#include "common/scoped_ptr.h" #include "google_breakpad/processor/call_stack.h" #include "google_breakpad/processor/memory_region.h" #include "google_breakpad/processor/source_line_resolver_interface.h" #include "google_breakpad/processor/stack_frame_cpu.h" #include "processor/cfi_frame_info.h" #include "processor/logging.h" -#include "processor/scoped_ptr.h" #include "processor/stackwalker_amd64.h" namespace google_breakpad { diff --git a/src/processor/stackwalker_arm.cc b/src/processor/stackwalker_arm.cc index da07fbcf..05df3d19 100644 --- a/src/processor/stackwalker_arm.cc +++ b/src/processor/stackwalker_arm.cc @@ -35,13 +35,13 @@ #include +#include "common/scoped_ptr.h" #include "google_breakpad/processor/call_stack.h" #include "google_breakpad/processor/memory_region.h" #include "google_breakpad/processor/source_line_resolver_interface.h" #include "google_breakpad/processor/stack_frame_cpu.h" #include "processor/cfi_frame_info.h" #include "processor/logging.h" -#include "processor/scoped_ptr.h" #include "processor/stackwalker_arm.h" namespace google_breakpad { diff --git a/src/processor/stackwalker_selftest.cc b/src/processor/stackwalker_selftest.cc index fdd15270..8c343eb9 100644 --- a/src/processor/stackwalker_selftest.cc +++ b/src/processor/stackwalker_selftest.cc @@ -64,6 +64,7 @@ #include +#include "common/scoped_ptr.h" #include "google_breakpad/common/breakpad_types.h" #include "google_breakpad/common/minidump_format.h" #include "google_breakpad/processor/basic_source_line_resolver.h" @@ -71,7 +72,6 @@ #include "google_breakpad/processor/memory_region.h" #include "google_breakpad/processor/stack_frame.h" #include "google_breakpad/processor/stack_frame_cpu.h" -#include "processor/scoped_ptr.h" using google_breakpad::BasicSourceLineResolver; using google_breakpad::CallStack; diff --git a/src/processor/stackwalker_x86.cc b/src/processor/stackwalker_x86.cc index 61d75ded..28e27809 100644 --- a/src/processor/stackwalker_x86.cc +++ b/src/processor/stackwalker_x86.cc @@ -35,6 +35,7 @@ #include +#include "common/scoped_ptr.h" #include "google_breakpad/processor/call_stack.h" #include "google_breakpad/processor/code_modules.h" #include "google_breakpad/processor/memory_region.h" @@ -42,7 +43,6 @@ #include "google_breakpad/processor/stack_frame_cpu.h" #include "processor/logging.h" #include "processor/postfix_evaluator-inl.h" -#include "processor/scoped_ptr.h" #include "processor/stackwalker_x86.h" #include "processor/windows_frame_info.h" #include "processor/cfi_frame_info.h" diff --git a/src/processor/static_contained_range_map_unittest.cc b/src/processor/static_contained_range_map_unittest.cc index 4c0c72d6..4ee47578 100644 --- a/src/processor/static_contained_range_map_unittest.cc +++ b/src/processor/static_contained_range_map_unittest.cc @@ -33,12 +33,11 @@ // Author: Siyang Xie (lambxsy@google.com) #include "breakpad_googletest_includes.h" +#include "common/scoped_ptr.h" #include "processor/contained_range_map-inl.h" #include "processor/static_contained_range_map-inl.h" #include "processor/simple_serializer-inl.h" #include "processor/map_serializers-inl.h" - -#include "processor/scoped_ptr.h" #include "processor/logging.h" namespace { diff --git a/src/processor/static_range_map_unittest.cc b/src/processor/static_range_map_unittest.cc index 82b26235..28217362 100644 --- a/src/processor/static_range_map_unittest.cc +++ b/src/processor/static_range_map_unittest.cc @@ -32,13 +32,13 @@ // Author: Siyang Xie (lambxsy@google.com) #include "breakpad_googletest_includes.h" +#include "common/scoped_ptr.h" #include "processor/range_map-inl.h" #include "processor/static_range_map-inl.h" #include "processor/simple_serializer-inl.h" #include "processor/map_serializers-inl.h" - #include "processor/logging.h" -#include "processor/scoped_ptr.h" + namespace { // Types used for testing. -- cgit v1.2.1