- Timestamp:
- Feb 19, 2006 1:29:42 AM (19 years ago)
- Location:
- pjproject/trunk/pjlib-util
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib-util/include/pjlib-util/xml.h
r123 r194 98 98 99 99 /** 100 * Clone XML node and all subnodes. 101 * 102 * @param pool Pool to allocate memory for new nodes. 103 * @param rhs The node to clone. 104 * 105 * @return Cloned XML node, or NULL on fail. 106 */ 107 PJ_DECL(pj_xml_node*) pj_xml_clone( pj_pool_t *pool, const pj_xml_node *rhs); 108 109 110 /** 100 111 * Create an empty node. 101 112 * -
pjproject/trunk/pjlib-util/src/pjlib-util/xml.c
r123 r194 47 47 static pj_xml_attr *alloc_attr( pj_pool_t *pool ) 48 48 { 49 return pj_pool_ calloc(pool, 1, sizeof(pj_xml_attr));49 return pj_pool_zalloc(pool, sizeof(pj_xml_attr)); 50 50 } 51 51 … … 115 115 } 116 116 117 pj_list_ insert_before( &node->attr_head, attr );117 pj_list_push_back( &node->attr_head, attr ); 118 118 } 119 119 … … 132 132 while (*scanner->curptr == '<' && *(scanner->curptr+1) != '/') { 133 133 pj_xml_node *sub_node = xml_parse_node(pool, scanner); 134 pj_list_ insert_before( &node->node_head, sub_node );134 pj_list_push_back( &node->node_head, sub_node ); 135 135 } 136 136 … … 332 332 PJ_DEF(void) pj_xml_add_node( pj_xml_node *parent, pj_xml_node *node ) 333 333 { 334 pj_list_ insert_before(&parent->node_head, node);334 pj_list_push_back(&parent->node_head, node); 335 335 } 336 336 337 337 PJ_DEF(void) pj_xml_add_attr( pj_xml_node *node, pj_xml_attr *attr ) 338 338 { 339 pj_list_ insert_before(&node->attr_head, attr);339 pj_list_push_back(&node->attr_head, attr); 340 340 } 341 341 … … 410 410 } 411 411 412 413 PJ_DEF(pj_xml_node*) pj_xml_clone( pj_pool_t *pool, const pj_xml_node *rhs) 414 { 415 pj_xml_node *node; 416 const pj_xml_attr *r_attr; 417 const pj_xml_node *child; 418 419 node = alloc_node(pool); 420 421 pj_strdup(pool, &node->name, &rhs->name); 422 pj_strdup(pool, &node->content, &rhs->content); 423 424 /* Clone all attributes */ 425 r_attr = rhs->attr_head.next; 426 while (r_attr != &rhs->attr_head) { 427 428 pj_xml_attr *attr; 429 430 attr = alloc_attr(pool); 431 pj_strdup(pool, &attr->name, &r_attr->name); 432 pj_strdup(pool, &attr->value, &r_attr->value); 433 434 pj_list_push_back(&node->attr_head, attr); 435 436 r_attr = r_attr->next; 437 } 438 439 /* Clone all child nodes. */ 440 child = rhs->node_head.next; 441 while (child != (pj_xml_node*) &rhs->node_head) { 442 pj_xml_node *new_child; 443 444 new_child = pj_xml_clone(pool, child); 445 pj_list_push_back(&node->node_head, new_child); 446 447 child = child->next; 448 } 449 450 return node; 451 }
Note: See TracChangeset
for help on using the changeset viewer.