Remove unnecessary GetPluginDirectoryPath interlocked caching
@@ -186,25 +186,13 @@ PPH_STRING PhpGetPluginDirectoryPath(
VOID
)
{
- static PPH_STRING cachedPluginDirectory = NULL;
PPH_STRING pluginsDirectory;
PPH_STRING applicationDirectory;
-
- if (pluginsDirectory = InterlockedCompareExchangePointer(
- &cachedPluginDirectory,
- NULL,
- NULL
- ))
- {
- return PhReferenceObject(pluginsDirectory);
- }
-
- if (applicationDirectory = PhGetApplicationDirectoryWin32())
- {
SIZE_T returnLength;
PH_FORMAT format[3];
WCHAR pluginsDirectoryPath[MAX_PATH];
+ applicationDirectory = PhGetApplicationDirectoryWin32();
PhInitFormatSR(&format[0], applicationDirectory->sr);
PhInitFormatS(&format[1], L"plugins");
PhInitFormatC(&format[2], OBJ_NAME_PATH_SEPARATOR);
@@ -222,24 +210,14 @@ PPH_STRING PhpGetPluginDirectoryPath(
pluginsDirectoryPathSr.Buffer = pluginsDirectoryPath;
pluginsDirectoryPathSr.Length = returnLength - sizeof(UNICODE_NULL);
- PhMoveReference(&pluginsDirectory, PhCreateString2(&pluginsDirectoryPathSr));
+ pluginsDirectory = PhCreateString2(&pluginsDirectoryPathSr);
}
else
{
- PhMoveReference(&pluginsDirectory, PhFormat(format, RTL_NUMBER_OF(format), MAX_PATH));
+ pluginsDirectory = PhFormat(format, RTL_NUMBER_OF(format), MAX_PATH);
}
PhDereferenceObject(applicationDirectory);
- }
-
- if (!InterlockedCompareExchangePointer(
- &cachedPluginDirectory,
- pluginsDirectory,
- NULL
- ))
- {
- PhReferenceObject(pluginsDirectory);
- }
return pluginsDirectory;
}
