MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / append_buffer

Method append_buffer

lib/pugixml/src/pugixml.cpp:6144–6177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6142 }
6143
6144 PUGI__FN xml_parse_result xml_node::append_buffer(const void* contents, size_t size, unsigned int options, xml_encoding encoding)
6145 {
6146 // append_buffer is only valid for elements/documents
6147 if (!impl::allow_insert_child(type(), node_element)) return impl::make_parse_result(status_append_invalid_root);
6148
6149 // get document node
6150 impl::xml_document_struct* doc = &impl::get_document(_root);
6151
6152 // disable document_buffer_order optimization since in a document with multiple buffers comparing buffer pointers does not make sense
6153 doc->header |= impl::xml_memory_page_contents_shared_mask;
6154
6155 // get extra buffer element (we'll store the document fragment buffer there so that we can deallocate it later)
6156 impl::xml_memory_page* page = 0;
6157 impl::xml_extra_buffer* extra = static_cast<impl::xml_extra_buffer*>(doc->allocate_memory(sizeof(impl::xml_extra_buffer) + sizeof(void*), page));
6158 (void)page;
6159
6160 if (!extra) return impl::make_parse_result(status_out_of_memory);
6161
6162 #ifdef PUGIXML_COMPACT
6163 // align the memory block to a pointer boundary; this is required for compact mode where memory allocations are only 4b aligned
6164 // note that this requires up to sizeof(void*)-1 additional memory, which the allocation above takes into account
6165 extra = reinterpret_cast<impl::xml_extra_buffer*>((reinterpret_cast<uintptr_t>(extra) + (sizeof(void*) - 1)) & ~(sizeof(void*) - 1));
6166 #endif
6167
6168 // add extra buffer to the list
6169 extra->buffer = 0;
6170 extra->next = doc->extra_buffers;
6171 doc->extra_buffers = extra;
6172
6173 // name of the root has to be NULL before parsing - otherwise closing node mismatches will not be detected at the top level
6174 impl::name_null_sentry sentry(_root);
6175
6176 return impl::load_buffer_impl(doc, _root, const_cast<void*>(contents), size, options, encoding, false, false, &extra->buffer);
6177 }
6178
6179 PUGI__FN xml_node xml_node::find_child_by_attribute(const char_t* name_, const char_t* attr_name, const char_t* attr_value) const
6180 {

Callers

nothing calls this directly

Calls 4

allow_insert_childFunction · 0.85
typeFunction · 0.85
make_parse_resultFunction · 0.85
allocate_memoryMethod · 0.80

Tested by

no test coverage detected