Use custom isc_mem based allocator for libxml2

The libxml2 library provides a way to replace the default allocator with
user supplied allocator (malloc, realloc, strdup and free).

Create a memory context specifically for libxml2 to allow tracking the
memory usage that has originated from within libxml2.  This will provide
a separate memory context for libxml2 to track the allocations and when
shutting down the application it will check that all libxml2 allocations
were returned to the allocator.

Additionally, move the xmlInitParser() and xmlCleanupParser() calls from
bin/named/main.c to library constructor/destructor in libisc library.
This commit is contained in:
Ondřej Surý
2022-09-23 14:36:54 +02:00
parent 236d4b7739
commit e537fea861
5 changed files with 110 additions and 8 deletions

View File

@@ -19,6 +19,7 @@
#include <isc/tls.h>
#include <isc/util.h>
#include <isc/uv.h>
#include <isc/xml.h>
#include "config.h"
#include "mem_p.h"
@@ -47,11 +48,13 @@ isc__initialize(void) {
isc__tls_initialize();
isc__trampoline_initialize();
isc__uv_initialize();
isc__xml_initialize();
(void)isc_os_ncpus();
}
void
isc__shutdown(void) {
isc__xml_shutdown();
isc__uv_shutdown();
isc__trampoline_shutdown();
isc__tls_shutdown();