summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/fcxml.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/src/fcxml.c b/src/fcxml.c
index 6b0f613..82a46f2 100644
--- a/src/fcxml.c
+++ b/src/fcxml.c
@@ -59,6 +59,10 @@
#ifdef _WIN32
#include <mbstring.h>
extern FcChar8 fontconfig_instprefix[];
+pfnGetSystemWindowsDirectory pGetSystemWindowsDirectory = NULL;
+pfnSHGetFolderPathA pSHGetFolderPathA = NULL;
+static void
+_ensureWin32GettersReady();
#endif
static FcChar8 *__fc_userdir = NULL;
@@ -1384,6 +1388,7 @@ _get_real_paths_from_prefix(FcConfigParse *parse, const FcChar8 *path, const FcC
{
int rc;
path = buffer;
+ _ensureWin32GettersReady();
rc = pGetSystemWindowsDirectory ((LPSTR) buffer, sizeof (buffer) - 20);
if (rc == 0 || rc > sizeof (buffer) - 20)
{
@@ -3451,11 +3456,6 @@ bail0:
return ret || !complain;
}
-#ifdef _WIN32
-pfnGetSystemWindowsDirectory pGetSystemWindowsDirectory = NULL;
-pfnSHGetFolderPathA pSHGetFolderPathA = NULL;
-#endif
-
static FcBool
FcConfigParseAndLoadFromMemoryInternal (FcConfig *config,
const FcChar8 *filename,
@@ -3601,19 +3601,7 @@ _FcConfigParse (FcConfig *config,
FcStrBufInit (&reason, NULL, 0);
#ifdef _WIN32
- if (!pGetSystemWindowsDirectory)
- {
- HMODULE hk32 = GetModuleHandleA("kernel32.dll");
- if (!(pGetSystemWindowsDirectory = (pfnGetSystemWindowsDirectory) GetProcAddress(hk32, "GetSystemWindowsDirectoryA")))
- pGetSystemWindowsDirectory = (pfnGetSystemWindowsDirectory) GetWindowsDirectory;
- }
- if (!pSHGetFolderPathA)
- {
- HMODULE hSh = LoadLibraryA("shfolder.dll");
- /* the check is done later, because there is no provided fallback */
- if (hSh)
- pSHGetFolderPathA = (pfnSHGetFolderPathA) GetProcAddress(hSh, "SHGetFolderPathA");
- }
+ _ensureWin32GettersReady();
#endif
filename = FcConfigGetFilename (config, name);
@@ -3736,6 +3724,26 @@ FcConfigParseAndLoadFromMemory (FcConfig *config,
return FcConfigParseAndLoadFromMemoryInternal (config, (const FcChar8 *)"memory", buffer, complain, FcTrue);
}
+#ifdef _WIN32
+static void
+_ensureWin32GettersReady()
+{
+ if (!pGetSystemWindowsDirectory)
+ {
+ HMODULE hk32 = GetModuleHandleA("kernel32.dll");
+ if (!(pGetSystemWindowsDirectory = (pfnGetSystemWindowsDirectory)GetProcAddress(hk32, "GetSystemWindowsDirectoryA")))
+ pGetSystemWindowsDirectory = (pfnGetSystemWindowsDirectory)GetWindowsDirectory;
+ }
+ if (!pSHGetFolderPathA)
+ {
+ HMODULE hSh = LoadLibraryA("shfolder.dll");
+ /* the check is done later, because there is no provided fallback */
+ if (hSh)
+ pSHGetFolderPathA = (pfnSHGetFolderPathA)GetProcAddress(hSh, "SHGetFolderPathA");
+ }
+}
+#endif // _WIN32
+
#define __fcxml__
#include "fcaliastail.h"
#undef __fcxml__