Skip to main content

xmlTextReaderPreservePattern

Function xmlTextReaderPreservePattern 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn xmlTextReaderPreservePattern( reader: *mut XmlTextReader, pattern: *const xmlChar, namespaces: *mut *const xmlChar, ) -> c_int
Expand description

int xmlTextReaderPreservePattern(xmlTextReaderPtr reader, const xmlChar *pattern, const xmlChar **namespaces).

Compiles the XPath-subset pattern (upstream xmlPatterncompile) and registers it like upstream reader->patternTab; after the parse, matched nodes and their element ancestors are kept and every other node is unlinked and freed (upstream’s NODE_IS_PRESERVED streaming prune, applied post-parse by the candidate’s whole-tree reader). Returns the index of the registered pattern, or -1 on error (upstream xmlreader.c xmlTextReaderPreservePattern).

§SAFETY

  • reader must be valid pointers (or NULL where the upstream C contract allows), obtained from the matching constructor/owner and not yet freed; the callee may take or keep ownership exactly as the C API specifies.

  • pattern must point to a valid NUL-terminated string; namespaces must be NULL or a NULL-terminated array of NUL-terminated strings, both live for the duration of the call.

The caller must not race this call with concurrent mutation of the same objects from other threads (per-object state is not internally synchronized). Violating any of the above is undefined behavior.

Exercised by the Phase-12 EXTERNAL-CONSUMERS court (reader3.c).