git/compat/win32
Johannes Schindelin db2f7c48cb Win32: simplify loading of DLL functions
Dynamic loading of DLL functions is duplicated in several places in Git
for Windows' source code.

This patch adds a pair of macros to simplify the process: the
DECLARE_PROC_ADDR(<dll>, <return-type>, <function-name>,
...<function-parameter-types>...) macro to be used at the beginning of a
code block, and the INIT_PROC_ADDR(<function-name>) macro to call before
using the declared function. The return value of the INIT_PROC_ADDR()
call has to be checked; If it is NULL, the function was not found in the
specified DLL.

Example:

        DECLARE_PROC_ADDR(kernel32.dll, BOOL, CreateHardLinkW,
                          LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES);

        if (!INIT_PROC_ADDR(CreateHardLinkW))
                return error("Could not find CreateHardLinkW() function";

	if (!CreateHardLinkW(source, target, NULL))
		return error("could not create hardlink from %S to %S",
			     source, target);
	return 0;

Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-09-26 11:02:49 +09:00
..
alloca.h mingw: activate alloca 2014-04-09 10:08:35 -07:00
dirent.c Win32: Unicode file name support (dirent) 2014-07-15 11:19:09 -07:00
dirent.h Win32: Unicode file name support (dirent) 2014-07-15 11:19:09 -07:00
lazyload.h Win32: simplify loading of DLL functions 2017-09-26 11:02:49 +09:00
pthread.c compat/win32/pthread.c: Fix a sparse warning 2013-04-28 12:26:45 -07:00
pthread.h Merge branch 'jk/push-client-deadlock-fix' 2016-05-18 15:11:46 -07:00
syslog.c win32: plug memory leak on realloc() failure in syslog() 2017-08-10 13:57:52 -07:00
syslog.h mingw: implement syslog 2010-11-04 16:53:49 -07:00