| // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| #ifndef BASE_WIN_SCOPED_CO_MEM_H_ |
| #define BASE_WIN_SCOPED_CO_MEM_H_ |
| #include "base/logging.h" |
| // Simple scoped memory releaser class for COM allocated memory. |
| // base::win::ScopedCoMem<ITEMIDLIST> file_item; |
| // SHGetSomeInfo(&file_item, ...); |
| // return; <-- memory released |
| ScopedCoMem() : mem_ptr_(NULL) {} |
| T** operator&() { // NOLINT |
| DCHECK(mem_ptr_ == NULL); // To catch memory leaks. |
| DCHECK(mem_ptr_ != NULL); |
| const T* operator->() const { |
| DCHECK(mem_ptr_ != NULL); |
| DISALLOW_COPY_AND_ASSIGN(ScopedCoMem); |
| #endif // BASE_WIN_SCOPED_CO_MEM_H_ |