You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by iv...@apache.org on 2019/05/16 19:01:28 UTC
svn commit: r1859404 - /apr/apr/trunk/misc/win32/misc.c
Author: ivan
Date: Thu May 16 19:01:28 2019
New Revision: 1859404
URL: http://svn.apache.org/viewvc?rev=1859404&view=rev
Log:
Refactoring: Combine lateDllName and lateDllHandle arrays to one array of
structures.
Modified:
apr/apr/trunk/misc/win32/misc.c
Modified: apr/apr/trunk/misc/win32/misc.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/misc/win32/misc.c?rev=1859404&r1=1859403&r2=1859404&view=diff
==============================================================================
--- apr/apr/trunk/misc/win32/misc.c (original)
+++ apr/apr/trunk/misc/win32/misc.c Thu May 16 19:01:28 2019
@@ -138,32 +138,40 @@ apr_status_t apr_get_oslevel(apr_oslevel
* missing from one or more releases of the Win32 API
*/
-static const char* const lateDllName[DLL_defined] = {
- "kernel32", "advapi32", "mswsock", "ws2_32", "shell32", "ntdll.dll",
- "Iphplapi" };
-static HMODULE lateDllHandle[DLL_defined] = {
- NULL, NULL, NULL, NULL, NULL, NULL,
- NULL };
+typedef struct win32_late_dll_t {
+ const char *dll_name;
+ HMODULE dll_handle;
+} win32_late_dll_t;
+
+static win32_late_dll_t late_dll[DLL_defined] = {
+ {"kernel32", NULL},
+ {"advapi32", NULL},
+ {"mswsock", NULL},
+ {"ws2_32", NULL},
+ {"shell32", NULL},
+ {"ntdll.dll", NULL},
+ {"Iphplapi", NULL}
+};
FARPROC apr_load_dll_func(apr_dlltoken_e fnLib, char* fnName, int ordinal)
{
- if (!lateDllHandle[fnLib]) {
- lateDllHandle[fnLib] = LoadLibraryA(lateDllName[fnLib]);
- if (!lateDllHandle[fnLib])
+ if (!late_dll[fnLib].dll_handle) {
+ late_dll[fnLib].dll_handle = LoadLibraryA(late_dll[fnLib].dll_name);
+ if (!late_dll[fnLib].dll_handle)
return NULL;
}
#if defined(_WIN32_WCE)
if (ordinal)
- return GetProcAddressA(lateDllHandle[fnLib], (const char *)
- (apr_ssize_t)ordinal);
+ return GetProcAddressA(late_dll[fnLib].dll_handle,
+ (const char *) (apr_ssize_t)ordinal);
else
- return GetProcAddressA(lateDllHandle[fnLib], fnName);
+ return GetProcAddressA(late_dll[fnLib].dll_handle, fnName);
#else
if (ordinal)
- return GetProcAddress(lateDllHandle[fnLib], (const char *)
- (apr_ssize_t)ordinal);
+ return GetProcAddress(late_dll[fnLib].dll_handle,
+ (const char *) (apr_ssize_t)ordinal);
else
- return GetProcAddress(lateDllHandle[fnLib], fnName);
+ return GetProcAddress(late_dll[fnLib].dll_handle, fnName);
#endif
}