From 67af66d7dbeac3bd0aaf86662cb417fcdad454b3 Mon Sep 17 00:00:00 2001 From: David Wrighton Date: Mon, 18 Dec 2023 16:29:04 -0800 Subject: [PATCH] Fix code review nits --- src/coreclr/vm/classhash.cpp | 8 ++++---- src/coreclr/vm/clsload.cpp | 11 ++++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/coreclr/vm/classhash.cpp b/src/coreclr/vm/classhash.cpp index e49c13bf46e3c9..5d2be11c9b3280 100644 --- a/src/coreclr/vm/classhash.cpp +++ b/src/coreclr/vm/classhash.cpp @@ -233,10 +233,10 @@ VOID EEClassHashTable::ConstructKeyFromData(PTR_EEClassHashEntry pEntry, // IN _ASSERTE(!(IsCaseInsensitiveTable() && FORBIDGC_LOADER_USE_ENABLED())); #endif - // cqb - If IsCaseInsensitiveTable() is true for the hash table, the bytes in Key will be allocated - // from cqb. This is to prevent wasting bytes in the Loader Heap. Thusly, it is important to note that - // in this case, the lifetime of Key is bounded by the lifetime of cqb, which will free the memory - // it allocated on destruction. + // If IsCaseInsensitiveTable() is true for the hash table, strings passed to the ConstructKeyCallback instance + // will be dynamically allocated. This is to prevent wasting bytes in the Loader Heap. Thusly, it is important + // to note that in this case, the lifetime of Key is bounded by the lifetime of the single call to UseKeys, and + // will be freed when that function returns. _ASSERTE(m_pModule != NULL); LPSTR pszName = NULL; diff --git a/src/coreclr/vm/clsload.cpp b/src/coreclr/vm/clsload.cpp index 7b4e24dba6bd0c..cfcf79c2ffa22d 100644 --- a/src/coreclr/vm/clsload.cpp +++ b/src/coreclr/vm/clsload.cpp @@ -3583,11 +3583,12 @@ VOID ClassLoader::AddExportedTypeDontHaveLock(Module *pManifestModule, CONTRACTL_END CrstHolder ch(&m_AvailableClassLock); + SArray exportedEntries; AddExportedTypeHaveLock( pManifestModule, cl, - NULL, + &exportedEntries, pamTracker); } @@ -3630,7 +3631,7 @@ VOID ClassLoader::AddExportedTypeHaveLock(Module *pManifestModule, { COUNT_T exportedEntryIndex = RidFromToken(mdImpl) - 1; _ASSERTE(RidFromToken(mdImpl) < RidFromToken(cl)); - if (exportedEntries != NULL && exportedEntries->GetCount() > exportedEntryIndex) + if (exportedEntries->GetCount() > exportedEntryIndex) { pEncloser = (*exportedEntries)[exportedEntryIndex]; } @@ -3669,11 +3670,11 @@ VOID ClassLoader::AddExportedTypeHaveLock(Module *pManifestModule, } insertedEntry = InsertValue(pClassHash, pClassCaseInsHash, pszNameSpace, pszName, EEClassHashTable::CompressClassDef(cl), pEncloser, pamTracker); + _ASSERTE(insertedEntry != NULL); - if (exportedEntries != NULL) + COUNT_T exportedEntryIndex = RidFromToken(cl) - 1; + if (classEntryIndex < exportedEntries->GetCount()) { - COUNT_T exportedEntryIndex = RidFromToken(cl) - 1; - _ASSERTE(exportedEntryIndex < exportedEntries->GetCount()); (*exportedEntries)[exportedEntryIndex] = insertedEntry; } }