diff options
author | naga <naga@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-11-10 05:36:11 +0000 |
---|---|---|
committer | naga <naga@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-11-10 05:36:11 +0000 |
commit | 805b9ac11576e2a34f562af21d3fab1341614fbb (patch) | |
tree | f995ac1981fa323d1a117c607d32f028326f24f8 /apps | |
parent | f2d5398eecca7c54fe41a302755202f04834cdcc (diff) | |
download | ATCD-805b9ac11576e2a34f562af21d3fab1341614fbb.tar.gz |
Fixed the problem with the Binary and Linear Search code. - Done by
Vishal (using Naga's ACE builds)
Diffstat (limited to 'apps')
-rw-r--r-- | apps/gperf/src/Key_List.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/apps/gperf/src/Key_List.cpp b/apps/gperf/src/Key_List.cpp index df131d887e8..63492aaaac1 100644 --- a/apps/gperf/src/Key_List.cpp +++ b/apps/gperf/src/Key_List.cpp @@ -1688,13 +1688,22 @@ Key_List::string_sort (void) List_Node *curr; if(ptr->link) { - for(curr=ptr->link;curr->link;curr=curr->link) + List_Node *last_node = 0; + + for(curr = ptr->link; curr; curr = curr->link) { + // Chnage the link to next pointer. curr->next = curr->link; + + // Save the pointer for the last node. + if (curr->link == 0) + last_node = curr; } - curr->next = ptr->next; + + // Set the pointers, correctly. + last_node->next = ptr->next; ptr->next = ptr->link; - + ptr = last_node; } } |