Windows Critical sections not released correctly

For https://bugzilla.gnome.org/show_bug.cgi?id=737851
Based on report from mike.vanduzee@caris.com , we were missing calling
LeaveCriticalSection() when count was down to 0 hence not freeing
adequately the related resource.
Visual Studio 14 CTP defines snprintf()

For https://bugzilla.gnome.org/show_bug.cgi?id=737937

Visual Studio 14 CTP (the VS which comes with Windows 10) defines snprintf().
It could be seen as a good idea as snprintf() is part of the C99 standard but
unfortunately libxml2 as many packages defines snprintf as _snprintf, the
function to use for any previous versions of the Visual Studio runtime. More,
to avoid hiding/shadowing snprintf() declaration in stdio.h is protected by an
"#ifdef snprintf" followed by an "#error", so compilation fails.

But the fix is easy: the corresponding C/C++ compiler defines _MSC_VER to 1900
so it is enough to guard the snprintf define against it, cf. the attached patch
for win32config.h (from 2.9.1 "latest" tarball).
Fix and add const qualifiers

For https://bugzilla.gnome.org/show_bug.cgi?id=689483

It seems there are functions that do use the const qualifier for some of the
arguments, but it seems that there are a lot of functions that don't use it and
probably should.

So I created a patch against 2.9.0 that makes as much as possible const in
tree.h, and changed other files as needed.

There were a lot of cases like "const xmlNodePtr node".  This doesn't actually
do anything, there the *pointer* is constant not the object it points to. So I
changed those to "const xmlNode *node".

I also removed some consts, mostly in the Copy functions, because those
functions can actually modify the doc or node they copy from
Fix a couple of issues raised by make dist
Python generator bug raised by the const change

the doc methode for xmlDocGetRootElement wasn't generated anymore
Provide cmake module

* add libxml2-config.cmake.in template
* configure.ac: add libxml2-config.cmake.in to the configured file list
* Makefile.am: install libxml2-config.cmake under ${libdir}/cmake/libxml2

Signed-off-by: Samuel Martin <s.martin49@gmail.com>
xmlmemory: handle realloc properly

If realloc fails, free original pointer.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>