Proper fix for the MinGW 4.0.0 startup problem.

Here is the analysis of the problem by Keith Marshall:

------------------
No this is not a regression. mingwrt-3.20 relied on Microsoft's globbing
routine, (in MSVCRT.DLL); sometime between the original releases of
WinXP and Vista, Microsoft changed the behaviour of this, breaking it
irreparably in the process. Worse still, when advised of the breakage,
they refused to revert it, claiming that the now broken behaviour is
consistent with what they want in cmd.exe. Resolution: we fixed it in
mingwrt-4.0, by providing our own implementation of glob(), and taking the
opportunity this accorded to add an extra layer of POSIX compatibility,
(so it can also glob directory names); our mingwrt-4 startup code now
uses our glob() implementation, in preference to MSVCRT.DLL's.

I suspect that your analysis of this so-called bug is flawed. You
say you have replaced several of the memory management routines, but
conspicuously absent from your list is strdup(), which incurs a hidden
call to malloc(). During startup, your mingwrt-4 app calls glob(), which
in turn calls dirname(). Both of these calls are resolved by mingwrt-4,
but dirname() then calls strdup(), which is resolved by MSVCRT.DLL. That
strdup() represents a hidden call to malloc(), which must be resolved
by the malloc() in MSVCRT.DLL; it cannot be otherwise, because that
reference must be resolved when Microsoft link MSVCRT.DLL itself, and
they don't have your alternative implementation.

Subsequently, dirname() calls free() on the buffer it obtained from
MSVCRT.DLL's malloc(), but that reference is resolved in the context
of linking your application, and your replacement for free() takes
precedence over the MSVCRT.DLL implementation; ergo, you now have your
free() trying to release memory allocated by MSVCRT.DLL's malloc().

AFAICS, this bug lies squarely in your incomplete replacement memory
management implementation.
------------------

The proper fix was therefore to define strdup() in xmalloc.c when compiling
for Windows, so that when redefining malloc(), we ensure the MinGW startup
code will call our strdup() and not the Microsoft one.