* xmlCopyPropList: * @target: the element where the attributes will be grafted * @cur: the first attribute * * Create a copy of an attribute list. This function sets the * parent pointers of the copied attributes to @target but doesn't * set the attributes on the target element. * * Returns the head of the copied list or NULL if a memory * allocation failed. */
| 4138 | * allocation failed. |
| 4139 | */ |
| 4140 | xmlAttrPtr |
| 4141 | xmlCopyPropList(xmlNodePtr target, xmlAttrPtr cur) { |
| 4142 | xmlAttrPtr ret = NULL; |
| 4143 | xmlAttrPtr p = NULL,q; |
| 4144 | |
| 4145 | if ((target != NULL) && (target->type != XML_ELEMENT_NODE)) |
| 4146 | return(NULL); |
| 4147 | while (cur != NULL) { |
| 4148 | q = xmlCopyProp(target, cur); |
| 4149 | if (q == NULL) { |
| 4150 | xmlFreePropList(ret); |
| 4151 | return(NULL); |
| 4152 | } |
| 4153 | if (p == NULL) { |
| 4154 | ret = p = q; |
| 4155 | } else { |
| 4156 | p->next = q; |
| 4157 | q->prev = p; |
| 4158 | p = q; |
| 4159 | } |
| 4160 | cur = cur->next; |
| 4161 | } |
| 4162 | return(ret); |
| 4163 | } |
| 4164 | |
| 4165 | /* |
| 4166 | * NOTE about the CopyNode operations ! |
no test coverage detected