pub use crate::abi::allocator::{
xmlFreeImpl, xmlInitMemory, xmlMallocImpl, xmlMallocAtomicImpl, xmlMallocAtomicZero, xmlMallocZero,
xmlMemBlocks, xmlMemDisplay, xmlMemGet, xmlMemSetup, xmlMemShow, xmlMemStrdupImpl, xmlMemUsed,
xmlReallocImpl, xmlReallocZero,
};
pub fn init_memory() -> i32 {
xmlInitMemory()
}
pub fn cleanup_memory() {
}
#[cfg(test)]
mod tests {
use super::*;
use core::ffi::c_void;
#[test]
fn test_memory_module_delegates_to_allocator() {
unsafe {
let ptr = xmlMallocImpl(100);
assert!(!ptr.is_null());
xmlFreeImpl(ptr);
}
}
#[test]
fn test_memory_zero_alloc() {
unsafe {
let ptr = xmlMallocZero(64);
assert!(!ptr.is_null());
let bytes = core::slice::from_raw_parts(ptr as *const u8, 64);
assert!(bytes.iter().all(|&b| b == 0));
xmlFreeImpl(ptr);
}
}
}