aboutsummaryrefslogtreecommitdiff
path: root/lib/Support/Windows/PathV2.inc
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2010-12-06 04:28:13 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2010-12-06 04:28:13 +0000
commit7eec50bf4f9d050323c0da9ac61ac3b150e4e5b1 (patch)
tree14635865481562e8255888c96d8295006e3b6e33 /lib/Support/Windows/PathV2.inc
parent93e5ec2cba6656417c9502ad80709aeca5eac968 (diff)
Support/Windows: Add ScopedHandle and move some clients over to it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120987 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Windows/PathV2.inc')
-rw-r--r--lib/Support/Windows/PathV2.inc20
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/Support/Windows/PathV2.inc b/lib/Support/Windows/PathV2.inc
index f6f53714b0..6bd541e49c 100644
--- a/lib/Support/Windows/PathV2.inc
+++ b/lib/Support/Windows/PathV2.inc
@@ -113,15 +113,14 @@ namespace {
return success;
}
- struct AutoCryptoProvider {
- HCRYPTPROV CryptoProvider;
-
- ~AutoCryptoProvider() {
- ::CryptReleaseContext(CryptoProvider, 0);
- }
+ // Forwarder for ScopedHandle.
+ BOOL WINAPI CryptReleaseContext(HCRYPTPROV Provider) {
+ return ::CryptReleaseContext(Provider, 0);
+ }
- operator HCRYPTPROV() const {return CryptoProvider;}
- };
+ typedef ScopedHandle<HCRYPTPROV, HCRYPTPROV(INVALID_HANDLE_VALUE),
+ BOOL (WINAPI*)(HCRYPTPROV), CryptReleaseContext>
+ ScopedCryptContext;
}
namespace llvm {
@@ -503,13 +502,14 @@ error_code unique_file(const Twine &model, int &result_fd,
SmallVector<wchar_t, 128> random_path_utf16;
// Get a Crypto Provider for CryptGenRandom.
- AutoCryptoProvider CryptoProvider;
- if (!::CryptAcquireContextW(&CryptoProvider.CryptoProvider,
+ HCRYPTPROV HCPC;
+ if (!::CryptAcquireContextW(&HCPC,
NULL,
NULL,
PROV_RSA_FULL,
0))
return windows_error(::GetLastError());
+ ScopedCryptContext CryptoProvider(HCPC);
retry_random_path:
random_path_utf16.set_size(0);