1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-21 14:53:44 +03:00

parser: Remove unnecessary dict checks when freeing strings

The following strings are never allocated from a dict:

- xmlParserCtxt.version
- xmlParserCtxt.encoding
- xmlParserCtxt.extSubURI
- xmlParserCtxt.extSubSystem
- xmlDoc.version
- xmlDoc.encoding
- xmlDoc.URL
- xmlDTD.ExternalID
- xmlDTD.SystemID
- xmlID.value

Also make the struct members point to non-const chars to avoid casts
when freeing.
This commit is contained in:
Nick Wellnhofer
2025-06-22 20:12:48 +02:00
parent 607708b35f
commit 7c91385040
10 changed files with 59 additions and 68 deletions

View File

@@ -5483,16 +5483,6 @@ htmlNodeStatus(xmlNode *node ATTRIBUTE_UNUSED,
* New set (2.6.0) of simpler and more flexible APIs *
* *
************************************************************************/
/**
* Free a string if it is not owned by the "dict" dictionary in the
* current scope
*
* @param str a string
*/
#define DICT_FREE(str) \
if ((str) && ((!dict) || \
(xmlDictOwns(dict, (const xmlChar *)(str)) == 0))) \
xmlFree((char *)(str));
/**
* Reset a parser context