Use smart pointer for everything
This commit is contained in:
parent
1b9c9e40e3
commit
6b9371c4cd
6 changed files with 240 additions and 268 deletions
28
brightray/browser/win/scoped_hstring.cc
Normal file
28
brightray/browser/win/scoped_hstring.cc
Normal file
|
@ -0,0 +1,28 @@
|
|||
// Copyright (c) 2015 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-CHROMIUM file.
|
||||
|
||||
#include "browser/win/scoped_hstring.h"
|
||||
|
||||
#include <winstring.h>
|
||||
|
||||
ScopedHString::ScopedHString(const wchar_t* source)
|
||||
: str_(nullptr) {
|
||||
Set(source);
|
||||
}
|
||||
|
||||
ScopedHString::ScopedHString() : str_(nullptr) {
|
||||
}
|
||||
|
||||
ScopedHString::~ScopedHString() {
|
||||
if (str_)
|
||||
WindowsDeleteString(str_);
|
||||
}
|
||||
|
||||
void ScopedHString::Set(const wchar_t* source) {
|
||||
if (str_) {
|
||||
WindowsDeleteString(str_);
|
||||
str_ = nullptr;
|
||||
}
|
||||
WindowsCreateString(source, wcslen(source), &str_);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue