Changeset 259edd4 for protocols/jabber/xmltree.c
- Timestamp:
- 2006-10-12T17:48:58Z (17 years ago)
- Branches:
- master
- Children:
- a4effbf
- Parents:
- b56b220
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/xmltree.c
rb56b220 r259edd4 550 550 node->attr[i].value = g_strdup( value ); 551 551 } 552 553 int xt_remove_attr( struct xt_node *node, char *key ) 554 { 555 int i, last; 556 557 for( i = 0; node->attr[i].key; i ++ ) 558 if( strcmp( node->attr[i].key, key ) == 0 ) 559 break; 560 561 /* If we didn't find the attribute... */ 562 if( node->attr[i].key == NULL ) 563 return 0; 564 565 g_free( node->attr[i].key ); 566 g_free( node->attr[i].value ); 567 568 /* If it's the last, this is easy: */ 569 if( node->attr[i+1].key == NULL ) 570 { 571 node->attr[i].key = node->attr[i].value = NULL; 572 } 573 else /* It's also pretty easy, actually. */ 574 { 575 /* Find the last item. */ 576 for( last = i + 1; node->attr[last+1].key; last ++ ); 577 578 node->attr[i] = node->attr[last]; 579 node->attr[last].key = NULL; 580 node->attr[last].value = NULL; 581 } 582 583 /* Let's not bother with reallocating memory here. It takes time and 584 most packets don't stay in memory for long anyway. */ 585 586 return 1; 587 }
Note: See TracChangeset
for help on using the changeset viewer.