diff options
Diffstat (limited to 'WWW/Library/Implementation/HTList.c')
-rw-r--r-- | WWW/Library/Implementation/HTList.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/WWW/Library/Implementation/HTList.c b/WWW/Library/Implementation/HTList.c index fee62404..996bea3d 100644 --- a/WWW/Library/Implementation/HTList.c +++ b/WWW/Library/Implementation/HTList.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTList.c,v 1.18 2010/04/29 09:59:31 tom Exp $ + * $LynxId: HTList.c,v 1.19 2013/01/04 00:31:27 tom Exp $ * * A small List class HTList.c * ================== @@ -263,23 +263,23 @@ void *HTList_removeObjectAt(HTList *me, int position) HTList *temp = me; HTList *prevNode; int pos = position; + void *result = NULL; - if (!temp || pos < 0) - return NULL; - - prevNode = temp; - while ((temp = temp->next)) { - if (pos == 0) { - prevNode->next = temp->next; + if (temp != NULL && pos >= 0) { + prevNode = temp; + while ((temp = temp->next) != NULL) { + if (pos == 0) { + prevNode->next = temp->next; + result = temp->object; + FREE(temp); + break; + } prevNode = temp; - FREE(temp); - return prevNode->object; + pos--; } - prevNode = temp; - pos--; } - return NULL; /* Reached the end of the list */ + return result; } /* Unlink object from START of list (the Last one inserted |