HomeFreeBSD

ctld: Simplify XML parsing memory management

Description

ctld: Simplify XML parsing memory management

Use C++ STL containers (std::string, std::list) for the data structure
holding the parsed output of the XML configuration obtained from the
kernel. This simplifies the code in various places and removes the
need for manual memory freeing (which was incomplete).

Use a std::list of pairs of std::string objects for the port and LUN
attribute lists instead of an nvlist.

Use a std::vector<char> for the resizable buffer receiving XML results
via ioctl(). Also, reuse the buffer from CTL_LUN_LIST for
CTL_PORT_LIST rather than doing a free() only to turn around and
malloc() again. While here, split out the code for fetching and
parsing the XML into a separate function.

Sponsored by: Chelsio Communications
Pull Request: https://github.com/freebsd/freebsd-src/pull/1794

Details

Provenance
jhbAuthored on Aug 4 2025, 7:38 PM
Parents
rG888ec3a71912: ctld: Convert struct conf to a C++ class
Branches
Unknown
Tags
Unknown