- while not Is_Empty_List (Collection.Objects) loop
-
- -- Find the real head of the collection, skipping the dummy head
-
- Curr_Ptr := Head (Collection.Objects);
-
- -- If the dummy head is the only remaining node, all real objects
- -- have already been detached and finalized.
-
- if Is_Dummy_Head (Curr_Ptr) then
- exit;
- end if;
-
- -- Store the next node now since the detachment will destroy the
- -- reference to it.
-
- Next_Ptr := Curr_Ptr.Next;
-
- -- Remove the current node from the list
-
- Detach (Curr_Ptr);
+ -- Go through the Objects list, and finalize each one. There is no need
+ -- to detach items from the list, because the whole collection is about
+ -- to go away.