MCPcopy Create free account
hub / github.com/MyGUI/mygui / deallocate_string

Method deallocate_string

UnitTests/TestApp/pugixml.cpp:447–464  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

445 }
446
447 void deallocate_string(char_t* string)
448 {
449 // this function casts pointers through void* to avoid 'cast increases required alignment of target type' warnings
450 // we're guaranteed the proper (pointer-sized) alignment on the input string if it was allocated via allocate_string
451
452 // get header
453 xml_memory_string_header* header = static_cast<xml_memory_string_header*>(static_cast<void*>(string)) - 1;
454
455 // deallocate
456 size_t page_offset = offsetof(xml_memory_page, data) + header->page_offset;
457 xml_memory_page* page =
458 reinterpret_cast<xml_memory_page*>(static_cast<void*>(reinterpret_cast<char*>(header) - page_offset));
459
460 // if full_size == 0 then this string occupies the whole page
461 size_t full_size = header->full_size == 0 ? page->busy_size : header->full_size;
462
463 deallocate_memory(header, full_size, page);
464 }
465
466 xml_memory_page* _root;
467 size_t _busy_size;

Callers 3

destroy_attributeFunction · 0.45
destroy_nodeFunction · 0.45
strcpy_insituFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected