MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlCopyAttribute

Function xmlCopyAttribute

ThirdParty/libxml2/vtklibxml2/valid.c:1904–1946  ·  view source on GitHub ↗

* xmlCopyAttribute: * @attr: An attribute * * Build a copy of an attribute. * * Returns the new xmlAttributePtr or NULL in case of error. */

Source from the content-addressed store, hash-verified

1902 * Returns the new xmlAttributePtr or NULL in case of error.
1903 */
1904static void *
1905xmlCopyAttribute(void *payload, const xmlChar *name ATTRIBUTE_UNUSED) {
1906 xmlAttributePtr attr = (xmlAttributePtr) payload;
1907 xmlAttributePtr cur;
1908
1909 cur = (xmlAttributePtr) xmlMalloc(sizeof(xmlAttribute));
1910 if (cur == NULL)
1911 return(NULL);
1912 memset(cur, 0, sizeof(xmlAttribute));
1913 cur->type = XML_ATTRIBUTE_DECL;
1914 cur->atype = attr->atype;
1915 cur->def = attr->def;
1916 if (attr->tree != NULL) {
1917 cur->tree = xmlCopyEnumeration(attr->tree);
1918 if (cur->tree == NULL)
1919 goto error;
1920 }
1921 if (attr->elem != NULL) {
1922 cur->elem = xmlStrdup(attr->elem);
1923 if (cur->elem == NULL)
1924 goto error;
1925 }
1926 if (attr->name != NULL) {
1927 cur->name = xmlStrdup(attr->name);
1928 if (cur->name == NULL)
1929 goto error;
1930 }
1931 if (attr->prefix != NULL) {
1932 cur->prefix = xmlStrdup(attr->prefix);
1933 if (cur->prefix == NULL)
1934 goto error;
1935 }
1936 if (attr->defaultValue != NULL) {
1937 cur->defaultValue = xmlStrdup(attr->defaultValue);
1938 if (cur->defaultValue == NULL)
1939 goto error;
1940 }
1941 return(cur);
1942
1943error:
1944 xmlFreeAttribute(cur);
1945 return(NULL);
1946}
1947
1948/**
1949 * xmlCopyAttributeTable:

Callers

nothing calls this directly

Calls 3

xmlCopyEnumerationFunction · 0.85
xmlStrdupFunction · 0.85
xmlFreeAttributeFunction · 0.85

Tested by

no test coverage detected