Skip to main content

Module allocator

Module allocator 

Source
Expand description

C ABI allocator compatibility — xmlMemSetup, xmlMemGet, xmlMalloc, xmlFree, etc. (§58).

This module implements the complete memory hook system exposed by libxml2:

  • Global allocator function pointers (malloc, realloc, free, strdup)
  • xmlMemSetup() / xmlMemGet() — set/get allocator hooks
  • xmlGcMemSetup() / xmlGcMemGet() — GC-aware allocator hooks (wrappers)
  • xmlMalloc() / xmlMallocAtomic() / xmlRealloc() / xmlFree() / xmlMemStrdup()
  • xmlMemUsed() / xmlMemBlocks() — allocation tracking
  • xmlMemDisplay() / xmlMemShow() — debugging output

§Phase 1 status

Complete — all allocator APIs are implemented with thread-safe global state.

§Safety

Allocator hooks are unsafe because they operate on raw pointers and are called from C code. Every public function documents its safety contract.

Functions§

xmlCleanupMemory
Clean up the memory layer.
xmlFree
Free allocated memory.
xmlGcMemGet
Get GC-aware memory allocator functions.
xmlGcMemSetup
Set GC-aware memory allocator functions.
xmlInitMemory
Initialize the memory layer with debugging support.
xmlMalloc
Allocate memory.
xmlMallocAtomic
Allocate memory that will never contain pointers to other memory.
xmlMallocAtomicZero
Allocate zero-initialized memory (atomic variant).
xmlMallocZero
Allocate zero-initialized memory.
xmlMemBlocks
Return the current number of allocated blocks (approximate).
xmlMemDisplay
Display memory allocation information to a file.
xmlMemGet
Get the current memory allocator functions.
xmlMemSetup
Set custom memory allocator functions.
xmlMemShow
Show memory allocation information.
xmlMemStrdup
Duplicate a C string using the configured allocator.
xmlMemUsed
Return the total amount of memory currently allocated (approximate).
xmlRealloc
Reallocate memory.
xmlReallocZero
Reallocate and zero-initialize the new portion.