From 65e90b2d7a86383243e380b2658fad26dce370f0 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Wed, 8 Apr 2015 21:44:16 -0700 Subject: docs: Add docs folder from master --- docs/samples/custom_memory_management.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 docs/samples/custom_memory_management.cpp (limited to 'docs/samples/custom_memory_management.cpp') diff --git a/docs/samples/custom_memory_management.cpp b/docs/samples/custom_memory_management.cpp new file mode 100644 index 0000000..2cb5520 --- /dev/null +++ b/docs/samples/custom_memory_management.cpp @@ -0,0 +1,27 @@ +#include "pugixml.hpp" + +#include + +// tag::decl[] +void* custom_allocate(size_t size) +{ + return new (std::nothrow) char[size]; +} + +void custom_deallocate(void* ptr) +{ + delete[] static_cast(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(""); +} + +// vim:et -- cgit v1.2.3