From 3117219e7c343645d7cb3d3c19fbc6a126522695 Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine" Date: Thu, 24 Jun 2010 12:28:17 +0000 Subject: docs: Extracted sample code in a separate file, added stream loading sample prototype git-svn-id: http://pugixml.googlecode.com/svn/trunk@534 99668b35-9821-0410-8761-19e4c4f06640 --- docs/samples/custom_memory_management.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 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..01a2acf --- /dev/null +++ b/docs/samples/custom_memory_management.cpp @@ -0,0 +1,25 @@ +#include "pugixml.hpp" + +#include + +//[code_custom_memory_management_decl +void* custom_allocate(size_t size) +{ + return new (std::nothrow) char[size]; +} + +void custom_deallocate(void* ptr) +{ + delete[] static_cast(ptr); +} +//] + +int main() +{ +//[code_custom_memory_management_call + pugi::set_memory_management_functions(custom_allocate, custom_deallocate); +//] + + pugi::xml_document doc; + doc.load(""); +} -- cgit v1.2.3