blob: dc2c7205b8eee93dfab0db15d17b4d1507c30569 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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;
}
};
|