- Timestamp:
- 2006-09-26T13:30:54Z (18 years ago)
- Branches:
- master
- Children:
- 6baca2a
- Parents:
- 8e6c732
- Location:
- protocols/jabber
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/xmltree.c
r8e6c732 r022df46 351 351 } 352 352 353 struct xt_node *xt_dup( struct xt_node *node ) 354 { 355 struct xt_node *dup = g_new0( struct xt_node, 1 ); 356 struct xt_node *c, *dc = NULL; 357 int i; 358 359 /* Let's NOT copy the parent element here BTW! Only do it for children. */ 360 361 dup->name = g_strdup( node->name ); 362 dup->flags = node->flags; 363 if( node->text ) 364 { 365 dup->text = g_memdup( node->text, node->text_len + 1 ); 366 dup->text_len = node->text_len; 367 } 368 369 /* Count the number of attributes and allocate the new array. */ 370 for( i = 0; node->attr[i].key; i ++ ); 371 dup->attr = g_new0( struct xt_attr, i + 1 ); 372 373 /* Copy them all! */ 374 for( i --; i >= 0; i -- ) 375 { 376 dup->attr[i].key = g_strdup( node->attr[i].key ); 377 dup->attr[i].value = g_strdup( node->attr[i].value ); 378 } 379 380 /* This nice mysterious loop takes care of the children. */ 381 for( c = node->children; c; c = c->next ) 382 { 383 if( dc == NULL ) 384 dc = dup->children = xt_dup( c ); 385 else 386 dc = ( dc->next = xt_dup( c ) ); 387 388 dc->parent = dup; 389 } 390 391 return dup; 392 } 393 353 394 /* Frees a node. This doesn't clean up references to itself from parents! */ 354 395 void xt_free_node( struct xt_node *node ) -
protocols/jabber/xmltree.h
r8e6c732 r022df46 84 84 char *xt_to_string( struct xt_node *node ); 85 85 void xt_print( struct xt_node *node ); 86 struct xt_node *xt_dup( struct xt_node *node ); 86 87 void xt_free_node( struct xt_node *node ); 87 88 void xt_free( struct xt_parser *xt );
Note: See TracChangeset
for help on using the changeset viewer.