diff dep/pugixml/docs/samples/custom_memory_management.cpp @ 55:d10b6c6b432e

add xml lib, we will need to use it eventually
author Paper <mrpapersonic@gmail.com>
date Tue, 26 Sep 2023 12:37:08 -0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dep/pugixml/docs/samples/custom_memory_management.cpp	Tue Sep 26 12:37:08 2023 -0400
@@ -0,0 +1,27 @@
+#include "pugixml.hpp"
+
+#include <new>
+
+// tag::decl[]
+void* custom_allocate(size_t size)
+{
+    return new (std::nothrow) char[size];
+}
+
+void custom_deallocate(void* ptr)
+{
+    delete[] static_cast<char*>(ptr);
+}
+// end::decl[]
+
+int main()
+{
+// tag::call[]
+    pugi::set_memory_management_functions(custom_allocate, custom_deallocate);
+// end::call[]
+
+    pugi::xml_document doc;
+    doc.load_string("<node/>");
+}
+
+// vim:et