Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(600)

Side by Side Diff: base/win/scoped_bstr.cc

Issue 1467003002: Switch to static_assert in base/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: / Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/win/iat_patch_function.cc ('k') | base/win/scoped_comptr.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/win/scoped_bstr.h" 5 #include "base/win/scoped_bstr.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace base { 9 namespace base {
10 namespace win { 10 namespace win {
11 11
12 ScopedBstr::ScopedBstr(const char16* non_bstr) 12 ScopedBstr::ScopedBstr(const char16* non_bstr)
13 : bstr_(SysAllocString(non_bstr)) { 13 : bstr_(SysAllocString(non_bstr)) {
14 } 14 }
15 15
16 ScopedBstr::~ScopedBstr() { 16 ScopedBstr::~ScopedBstr() {
17 COMPILE_ASSERT(sizeof(ScopedBstr) == sizeof(BSTR), ScopedBstrSize); 17 static_assert(sizeof(ScopedBstr) == sizeof(BSTR), "ScopedBstrSize");
18 SysFreeString(bstr_); 18 SysFreeString(bstr_);
19 } 19 }
20 20
21 void ScopedBstr::Reset(BSTR bstr) { 21 void ScopedBstr::Reset(BSTR bstr) {
22 if (bstr != bstr_) { 22 if (bstr != bstr_) {
23 // if |bstr_| is NULL, SysFreeString does nothing. 23 // if |bstr_| is NULL, SysFreeString does nothing.
24 SysFreeString(bstr_); 24 SysFreeString(bstr_);
25 bstr_ = bstr; 25 bstr_ = bstr;
26 } 26 }
27 } 27 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 size_t ScopedBstr::Length() const { 62 size_t ScopedBstr::Length() const {
63 return SysStringLen(bstr_); 63 return SysStringLen(bstr_);
64 } 64 }
65 65
66 size_t ScopedBstr::ByteLength() const { 66 size_t ScopedBstr::ByteLength() const {
67 return SysStringByteLen(bstr_); 67 return SysStringByteLen(bstr_);
68 } 68 }
69 69
70 } // namespace win 70 } // namespace win
71 } // namespace base 71 } // namespace base
OLDNEW
« no previous file with comments | « base/win/iat_patch_function.cc ('k') | base/win/scoped_comptr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698