summaryrefslogtreecommitdiff
path: root/t/helper/test-drop-caches.c
diff options
context:
space:
mode:
Diffstat (limited to 't/helper/test-drop-caches.c')
-rw-r--r--t/helper/test-drop-caches.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/t/helper/test-drop-caches.c b/t/helper/test-drop-caches.c
index f125192..7b42784 100644
--- a/t/helper/test-drop-caches.c
+++ b/t/helper/test-drop-caches.c
@@ -1,6 +1,8 @@
+#include "test-tool.h"
#include "git-compat-util.h"
#if defined(GIT_WINDOWS_NATIVE)
+#include "lazyload.h"
static int cmd_sync(void)
{
@@ -84,8 +86,7 @@ static int cmd_dropcaches(void)
{
HANDLE hProcess = GetCurrentProcess();
HANDLE hToken;
- HMODULE ntdll;
- DWORD(WINAPI *NtSetSystemInformation)(INT, PVOID, ULONG);
+ DECLARE_PROC_ADDR(ntdll.dll, DWORD, NtSetSystemInformation, INT, PVOID, ULONG);
SYSTEM_MEMORY_LIST_COMMAND command;
int status;
@@ -97,14 +98,8 @@ static int cmd_dropcaches(void)
CloseHandle(hToken);
- ntdll = LoadLibrary("ntdll.dll");
- if (!ntdll)
- return error("Can't load ntdll.dll, wrong Windows version?");
-
- NtSetSystemInformation =
- (DWORD(WINAPI *)(INT, PVOID, ULONG))GetProcAddress(ntdll, "NtSetSystemInformation");
- if (!NtSetSystemInformation)
- return error("Can't get function addresses, wrong Windows version?");
+ if (!INIT_PROC_ADDR(NtSetSystemInformation))
+ return error("Could not find NtSetSystemInformation() function");
command = MemoryPurgeStandbyList;
status = NtSetSystemInformation(
@@ -117,8 +112,6 @@ static int cmd_dropcaches(void)
else if (status != STATUS_SUCCESS)
error("Unable to execute the memory list command %d", status);
- FreeLibrary(ntdll);
-
return status;
}
@@ -160,7 +153,7 @@ static int cmd_dropcaches(void)
#endif
-int cmd_main(int argc, const char **argv)
+int cmd__drop_caches(int argc, const char **argv)
{
cmd_sync();
return cmd_dropcaches();