diff options
author | Jiyoung Yun <jy910.yun@samsung.com> | 2016-11-23 19:09:09 +0900 |
---|---|---|
committer | Jiyoung Yun <jy910.yun@samsung.com> | 2016-11-23 19:09:09 +0900 |
commit | 4b4aad7217d3292650e77eec2cf4c198ea9c3b4b (patch) | |
tree | 98110734c91668dfdbb126fcc0e15ddbd93738ca /src/binder/assemblyidentitycache.cpp | |
parent | fa45f57ed55137c75ac870356a1b8f76c84b229c (diff) | |
download | coreclr-upstream/1.1.0.tar.gz coreclr-upstream/1.1.0.tar.bz2 coreclr-upstream/1.1.0.zip |
Imported Upstream version 1.1.0upstream/1.1.0
Diffstat (limited to 'src/binder/assemblyidentitycache.cpp')
-rw-r--r-- | src/binder/assemblyidentitycache.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/binder/assemblyidentitycache.cpp b/src/binder/assemblyidentitycache.cpp new file mode 100644 index 0000000000..dc2c7205b8 --- /dev/null +++ b/src/binder/assemblyidentitycache.cpp @@ -0,0 +1,72 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// ============================================================ +// +// AssemblyIdentityCache.cpp +// + + +// +// Implements the AssemblyIdentityCache class +// +// ============================================================ + +#define DISABLE_BINDER_DEBUG_LOGGING + +#include "assemblyidentitycache.hpp" + +namespace BINDER_SPACE +{ + AssemblyIdentityCache::AssemblyIdentityCache() : SHash<AssemblyIdentityHashTraits>::SHash() + { + // Nothing to do here + } + + AssemblyIdentityCache::~AssemblyIdentityCache() + { + // Delete entries and contents array + for (Hash::Iterator i = Hash::Begin(), end = Hash::End(); i != end; i++) + { + const AssemblyIdentityCacheEntry *pAssemblyIdentityCacheEntry = *i; + delete pAssemblyIdentityCacheEntry; + } + RemoveAll(); + } + + HRESULT AssemblyIdentityCache::Add(LPCSTR szTextualIdentity, + AssemblyIdentityUTF8 *pAssemblyIdentity) + { + HRESULT hr = S_OK; + BINDER_LOG_ENTER(L"AssemblyIdentityCache::Add"); + + NewHolder<AssemblyIdentityCacheEntry> pAssemblyIdentityCacheEntry; + SAFE_NEW(pAssemblyIdentityCacheEntry, AssemblyIdentityCacheEntry); + + pAssemblyIdentityCacheEntry->SetTextualIdentity(szTextualIdentity); + pAssemblyIdentityCacheEntry->SetAssemblyIdentity(pAssemblyIdentity); + + Hash::Add(pAssemblyIdentityCacheEntry); + pAssemblyIdentityCacheEntry.SuppressRelease(); + + Exit: + BINDER_LOG_LEAVE_HR(L"AssemblyIdentityCache::Add", hr); + return hr; + } + + AssemblyIdentityUTF8 *AssemblyIdentityCache::Lookup(LPCSTR szTextualIdentity) + { + BINDER_LOG_ENTER(L"AssemblyIdentityCache::Lookup"); + AssemblyIdentityUTF8 *pAssemblyIdentity = NULL; + AssemblyIdentityCacheEntry *pAssemblyIdentityCacheEntry = Hash::Lookup(szTextualIdentity); + + if (pAssemblyIdentityCacheEntry != NULL) + { + BINDER_LOG(L"Found cached identity"); + pAssemblyIdentity = pAssemblyIdentityCacheEntry->GetAssemblyIdentity(); + } + + BINDER_LOG_LEAVE(L"AssemblyIdentityCache::Lookup"); + return pAssemblyIdentity; + } +}; |