22#include "git-compat-util.h"
33
44#if defined(GIT_WINDOWS_NATIVE )
5+ #include "lazyload.h"
56
67static int cmd_sync (void )
78{
@@ -82,8 +83,7 @@ static int cmd_dropcaches(void)
8283{
8384 HANDLE hProcess = GetCurrentProcess ();
8485 HANDLE hToken ;
85- HMODULE ntdll ;
86- DWORD (WINAPI * NtSetSystemInformation )(INT , PVOID , ULONG );
86+ DECLARE_PROC_ADDR (ntdll .dll , DWORD , NtSetSystemInformation , INT , PVOID , ULONG );
8787 SYSTEM_MEMORY_LIST_COMMAND command ;
8888 int status ;
8989
@@ -95,14 +95,8 @@ static int cmd_dropcaches(void)
9595
9696 CloseHandle (hToken );
9797
98- ntdll = LoadLibrary ("ntdll.dll" );
99- if (!ntdll )
100- return error ("Can't load ntdll.dll, wrong Windows version?" );
101-
102- NtSetSystemInformation =
103- (DWORD (WINAPI * )(INT , PVOID , ULONG ))GetProcAddress (ntdll , "NtSetSystemInformation" );
104- if (!NtSetSystemInformation )
105- return error ("Can't get function addresses, wrong Windows version?" );
98+ if (!INIT_PROC_ADDR (NtSetSystemInformation ))
99+ return error ("Could not find NtSetSystemInformation() function" );
106100
107101 command = MemoryPurgeStandbyList ;
108102 status = NtSetSystemInformation (
@@ -115,8 +109,6 @@ static int cmd_dropcaches(void)
115109 else if (status != STATUS_SUCCESS )
116110 error ("Unable to execute the memory list command %d" , status );
117111
118- FreeLibrary (ntdll );
119-
120112 return status ;
121113}
122114
0 commit comments