Mercurial > minori
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 54:466ac9870df9 | 55:d10b6c6b432e |
|---|---|
| 1 #include "pugixml.hpp" | |
| 2 | |
| 3 #include <new> | |
| 4 | |
| 5 // tag::decl[] | |
| 6 void* custom_allocate(size_t size) | |
| 7 { | |
| 8 return new (std::nothrow) char[size]; | |
| 9 } | |
| 10 | |
| 11 void custom_deallocate(void* ptr) | |
| 12 { | |
| 13 delete[] static_cast<char*>(ptr); | |
| 14 } | |
| 15 // end::decl[] | |
| 16 | |
| 17 int main() | |
| 18 { | |
| 19 // tag::call[] | |
| 20 pugi::set_memory_management_functions(custom_allocate, custom_deallocate); | |
| 21 // end::call[] | |
| 22 | |
| 23 pugi::xml_document doc; | |
| 24 doc.load_string("<node/>"); | |
| 25 } | |
| 26 | |
| 27 // vim:et |
