diff options
author | Junio C Hamano <gitster@pobox.com> | 2018-05-23 14:38:22 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-05-23 14:38:22 +0900 |
commit | fda537adbaee0bc7423c734c9c662f9f6641c5c4 (patch) | |
tree | c68380c18120e043501e92bef127a24baa7fd5b8 /t/helper | |
parent | Merge branch 'en/unpack-trees-split-index-fix' (diff) | |
parent | test-drop-caches: simplify delay loading of NtSetSystemInformation (diff) | |
download | tgif-fda537adbaee0bc7423c734c9c662f9f6641c5c4.tar.xz |
Merge branch 'bp/test-drop-caches'
Code simplification.
* bp/test-drop-caches:
test-drop-caches: simplify delay loading of NtSetSystemInformation
Diffstat (limited to 't/helper')
-rw-r--r-- | t/helper/test-drop-caches.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/t/helper/test-drop-caches.c b/t/helper/test-drop-caches.c index 838760898b..d6bcfddf13 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; } |