summaryrefslogtreecommitdiff
path: root/t/helper/test-drop-caches.c
diff options
context:
space:
mode:
authorBen Peart <Ben.Peart@microsoft.com>2018-05-01 12:46:22 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-05-04 02:35:00 (GMT)
commit447ed832e5ce50e4dc98dd53e0bbcf3e1a338f35 (patch)
tree4c7ead1cf690e14b17d70aeb36d33ee61eeeccf1 /t/helper/test-drop-caches.c
parent1f1cddd558b54bb0ce19c8ace353fd07b758510d (diff)
downloadgit-447ed832e5ce50e4dc98dd53e0bbcf3e1a338f35.zip
git-447ed832e5ce50e4dc98dd53e0bbcf3e1a338f35.tar.gz
git-447ed832e5ce50e4dc98dd53e0bbcf3e1a338f35.tar.bz2
test-drop-caches: simplify delay loading of NtSetSystemInformation
Take advantage of the recent addition of support for lazy loading functions[1] on Windows to simplify the loading of NtSetSystemInformation. [1] db2f7c48cb (Win32: simplify loading of DLL functions, 2017-09-25) Signed-off-by: Ben Peart <benpeart@microsoft.com> Reviewed-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/helper/test-drop-caches.c')
-rw-r--r--t/helper/test-drop-caches.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/t/helper/test-drop-caches.c b/t/helper/test-drop-caches.c
index 8387608..d6bcfdd 100644
--- a/t/helper/test-drop-caches.c
+++ b/t/helper/test-drop-caches.c
@@ -2,6 +2,7 @@
#include "git-compat-util.h"
#if defined(GIT_WINDOWS_NATIVE)
+#include "lazyload.h"
static int cmd_sync(void)
{
@@ -82,8 +83,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;
@@ -95,14 +95,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(
@@ -115,8 +109,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;
}