Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
例如:
xmlDocPtr parseDoc() { buf = malloc(12); strncpy(buf, "<document/>", 12); xmlDocPtr doc = xmlParseDoc(buf); free(buf); /*** is this safe? ***/ return doc; }
文档有点模糊,不清楚生成的树是否包含来自原始缓冲区的所有信息,或者它是否需要缓冲区保持有效。
是的,您可以在解析后释放缓冲区。我还建议使用xmlReadMemory来解析内存中的文档。它有一些有用的选项。