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.

Statics§

xmlFree
xmlFreeFunc xmlFree — the free hook.
xmlMalloc
xmlMallocFunc xmlMalloc — the malloc hook (default: xmlMallocImpl).
xmlMallocAtomic
xmlMallocFunc xmlMallocAtomic — the atomic-malloc hook.
xmlMemStrdup
xmlStrdupFunc xmlMemStrdup — the strdup hook.
xmlRealloc
xmlReallocFunc xmlRealloc — the realloc hook.

Functions§

xmlCleanupMemory
Clean up the memory layer.
xmlFreeImpl
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.
xmlMallocAtomicImpl
Allocate memory that will never contain pointers to other memory.
xmlMallocAtomicLoc
Allocate zeroed memory, recording the allocation site (upstream xmlmemory.h).
xmlMallocAtomicZero
Allocate zero-initialized memory (atomic variant).
xmlMallocImpl
Allocate memory.
xmlMallocLoc
Allocate memory, recording the allocation site (upstream xmlmemory.h).
xmlMallocZero
Allocate zero-initialized memory.
xmlMemBlocks
Return the current number of allocated blocks (approximate).
xmlMemDisplay
Display memory allocation information to a file.
xmlMemDisplayLast
Display a limited amount of memory debug information (upstream xmlmemory.h).
xmlMemFree
Free memory (legacy name; same contract as xmlFree).
xmlMemGet
Get the current memory allocator functions.
xmlMemMalloc
Allocate memory (legacy name; same contract as xmlMalloc).
xmlMemRealloc
Reallocate memory (legacy name; same contract as xmlRealloc).
xmlMemSetup
Set custom memory allocator functions.
xmlMemShow
Show memory allocation information.
xmlMemSize
Return the size of an allocated block (upstream xmlmemory.h).
xmlMemStrdupImpl
Duplicate a C string using the configured allocator.
xmlMemStrdupLoc
Duplicate a string, recording the allocation site (upstream xmlmemory.h).
xmlMemUsed
Return the total amount of memory currently allocated (approximate).
xmlMemoryDump
Dump memory allocation statistics (upstream xmlmemory.h).
xmlMemoryStrdup
Duplicate a string (legacy name; same contract as xmlMemStrdup).
xmlReallocImpl
Reallocate memory.
xmlReallocLoc
Reallocate memory, recording the allocation site (upstream xmlmemory.h).
xmlReallocZero
Reallocate and zero-initialize the new portion.