diff options
author | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2009-01-06 13:14:13 +0000 |
---|---|---|
committer | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2009-01-06 13:14:13 +0000 |
commit | e305a07249fa8b772319d12f7657373cbb71173d (patch) | |
tree | 1f22396cebd552183ed261f92978744b5f8d2ae8 /src/pugixml.hpp | |
parent | 5054325378a67e1480fe2474836f6f5a919dc4bc (diff) |
Custom memory management functions implemented
git-svn-id: http://pugixml.googlecode.com/svn/trunk@105 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'src/pugixml.hpp')
-rw-r--r-- | src/pugixml.hpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/pugixml.hpp b/src/pugixml.hpp index b1096fe..fd25077 100644 --- a/src/pugixml.hpp +++ b/src/pugixml.hpp @@ -1745,6 +1745,38 @@ namespace pugi */ std::wstring as_utf16(const char* str); #endif + + /** + * Memory allocation function + * + * \param size - allocation size + * \return pointer to allocated memory on success, NULL on failure + */ + typedef void* (*allocation_function)(size_t size); + + /** + * Memory deallocation function + * + * \param ptr - pointer to memory previously allocated by allocation function + */ + typedef void (*deallocation_function)(void* ptr); + + /** + * Override default memory management functions + * + * All subsequent allocations/deallocations will be performed via supplied functions. Take care not to + * change memory management functions if any xml_document instances are still alive - this is considered + * undefined behaviour (expect crashes/memory damages/etc.). + * + * \param allocate - allocation function + * \param deallocate - deallocation function + * + * \note XPath-related allocations, as well as allocations in functions that return std::string (xml_node::path, as_utf8, as_utf16) + * are not performed via these functions. + * \note If you're using parse() with ownership transfer, you have to allocate the buffer you pass to parse() with allocation + * function you set via this function. + */ + void set_memory_management_functions(allocation_function allocate, deallocation_function deallocate); } // Inline implementation |