Skip to main content

xmlGcMemSetup

Function xmlGcMemSetup 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn xmlGcMemSetup( freeFunc: Option<xmlFreeFunc>, mallocFunc: Option<xmlMallocFunc>, mallocAtomicFunc: Option<xmlMallocFunc>, reallocFunc: Option<xmlReallocFunc>, strdupFunc: Option<xmlStrdupFunc>, ) -> c_int
Expand description

Set GC-aware memory allocator functions (upstream xmlmemory.h).

§UPSTREAM-PARITY

int xmlGcMemSetup(xmlFreeFunc freeFunc,
                  xmlMallocFunc mallocFunc,
                  xmlMallocFunc mallocAtomicFunc,
                  xmlReallocFunc reallocFunc,
                  xmlStrdupFunc strdupFunc);

Same contract as xmlMemSetup with a dedicated mallocAtomicFunc for atomic allocations (upstream xmlmemory.c: xmlMallocAtomic = mallocAtomicFunc). Returns -1 if any function is NULL, else 0.

§SAFETY

  • All function pointers must be valid (non-null) and thread-safe
  • The functions must follow the C malloc/realloc/free/strdup contract
  • Must not race with concurrent allocation (upstream ordering contract)
  • The caller is responsible for ensuring the functions remain valid for the entire time they are installed