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 hooksxmlGcMemSetup()/xmlGcMemGet()— GC-aware allocator hooks (wrappers)xmlMalloc()/xmlMallocAtomic()/xmlRealloc()/xmlFree()/xmlMemStrdup()xmlMemUsed()/xmlMemBlocks()— allocation trackingxmlMemDisplay()/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).- xmlMalloc
Atomic xmlMallocFunc xmlMallocAtomic— the atomic-malloc hook.- xmlMem
Strdup xmlStrdupFunc xmlMemStrdup— the strdup hook.- xmlRealloc
xmlReallocFunc xmlRealloc— the realloc hook.
Functions§
- xmlCleanup
Memory - Clean up the memory layer.
- xmlFree
Impl ⚠ - Free allocated memory.
- xmlGc
MemGet ⚠ - Get GC-aware memory allocator functions.
- xmlGc
MemSetup ⚠ - Set GC-aware memory allocator functions.
- xmlInit
Memory - Initialize the memory layer with debugging support.
- xmlMalloc
Atomic ⚠Impl - Allocate memory that will never contain pointers to other memory.
- xmlMalloc
Atomic ⚠Loc - Allocate zeroed memory, recording the allocation site (upstream xmlmemory.h).
- xmlMalloc
Atomic ⚠Zero - Allocate zero-initialized memory (atomic variant).
- xmlMalloc
Impl ⚠ - Allocate memory.
- xmlMalloc
Loc ⚠ - Allocate memory, recording the allocation site (upstream xmlmemory.h).
- xmlMalloc
Zero ⚠ - Allocate zero-initialized memory.
- xmlMem
Blocks - Return the current number of allocated blocks (approximate).
- xmlMem
Display ⚠ - Display memory allocation information to a file.
- xmlMem
Display ⚠Last - Display a limited amount of memory debug information (upstream xmlmemory.h).
- xmlMem
Free ⚠ - Free memory (legacy name; same contract as
xmlFree). - xmlMem
Get ⚠ - Get the current memory allocator functions.
- xmlMem
Malloc ⚠ - Allocate memory (legacy name; same contract as
xmlMalloc). - xmlMem
Realloc ⚠ - Reallocate memory (legacy name; same contract as
xmlRealloc). - xmlMem
Setup ⚠ - Set custom memory allocator functions.
- xmlMem
Show ⚠ - Show memory allocation information.
- xmlMem
Size ⚠ - Return the size of an allocated block (upstream xmlmemory.h).
- xmlMem
Strdup ⚠Impl - Duplicate a C string using the configured allocator.
- xmlMem
Strdup ⚠Loc - Duplicate a string, recording the allocation site (upstream xmlmemory.h).
- xmlMem
Used - Return the total amount of memory currently allocated (approximate).
- xmlMemory
Dump ⚠ - Dump memory allocation statistics (upstream xmlmemory.h).
- xmlMemory
Strdup ⚠ - Duplicate a string (legacy name; same contract as
xmlMemStrdup). - xmlRealloc
Impl ⚠ - Reallocate memory.
- xmlRealloc
Loc ⚠ - Reallocate memory, recording the allocation site (upstream xmlmemory.h).
- xmlRealloc
Zero ⚠ - Reallocate and zero-initialize the new portion.