diff --git a/CREDITS b/CREDITS index c1e1ea62..93b4139d 100644 --- a/CREDITS +++ b/CREDITS @@ -65,4 +65,3 @@ Ciamac Moallemi Roger Mundt * troubleshooting and debugging help - diff --git a/src/daap-proto.c b/src/daap-proto.c index c87aa057..4e22c5ef 100644 --- a/src/daap-proto.c +++ b/src/daap-proto.c @@ -159,6 +159,7 @@ DAAP_BLOCK *daap_get_new(void) { pnew->value=NULL; pnew->parent=NULL; pnew->children=NULL; + pnew->last_child=NULL; pnew->next=NULL; return pnew; @@ -198,17 +199,13 @@ DAAP_BLOCK *daap_add_formatted(DAAP_BLOCK *parent, char *tag, /* walk the child list and put it at the end */ if(parent) { - current=last=parent->children; - while(current) { - last=current; - current=current->next; - } - - if(last) { /* some there already */ - last->next=pnew; - } else { - parent->children=pnew; - } + last = parent->last_child; + if (last) { + last->next = pnew; + } else { + parent->children = pnew; + } + parent->last_child = pnew; } /* now, walk the chain and update sizes */ diff --git a/src/daap-proto.h b/src/daap-proto.h index ce318a00..c55e99d8 100644 --- a/src/daap-proto.h +++ b/src/daap-proto.h @@ -51,6 +51,7 @@ typedef struct daap_block_tag { char svalue[4]; /* for statics up to 4 bytes */ struct daap_block_tag *parent; struct daap_block_tag *children; + struct daap_block_tag *last_child; struct daap_block_tag *next; } DAAP_BLOCK;