MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / new_xpath_variable

Function new_xpath_variable

Source/ThirdParty/pugixml/pugixml.cpp:7674–7688  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7672 }
7673
7674 template <typename T> PUGI__FN T* new_xpath_variable(const char_t* name)
7675 {
7676 size_t length = strlength(name);
7677 if (length == 0) return 0; // empty variable names are invalid
7678
7679 // $$ we can't use offsetof(T, name) because T is non-POD, so we just allocate additional length characters
7680 void* memory = xml_memory::allocate(sizeof(T) + length * sizeof(char_t));
7681 if (!memory) return 0;
7682
7683 T* result = new (memory) T();
7684
7685 memcpy(result->name, name, (length + 1) * sizeof(char_t));
7686
7687 return result;
7688 }
7689
7690 PUGI__FN xpath_variable* new_xpath_variable(xpath_value_type type, const char_t* name)
7691 {

Callers 1

addMethod · 0.85

Calls 2

strlengthFunction · 0.85
memcpyFunction · 0.85

Tested by

no test coverage detected