[haiku-commits] Re: haiku: hrev47638 - in src: kits/tracker servers/print

  • From: Stephan Aßmus <superstippi@xxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 7 Aug 2014 17:13:06 +0200

Hi,


Am 07.08.2014 um 08:50 schrieb pulkomandy@xxxxxxxxxxxxx:

> @@ -463,6 +465,11 @@ BPoseView::DeleteProperty(BMessage* specifier, int32 
> form,
>                               MoveListToTrash(entryList, false, false);
>                       } else
>                               Delete(entryList, false, 
> settings.AskBeforeDeleteFile());
> +             } else {
> +                     entry_ref* ref;
> +                     while (ref = entryList->RemoveItemAt(0))
> +                             delete ref;
> +                     delete entryList;
>               }

Multiple issues with this. It should even give a compiler warning about 
suggested parenthesis. So coding style and compiler warning corrected, it 
should be:

> +                     entry_ref* ref;
> +                     while ((ref = entryList->RemoveItemAt(0)) != NULL)
> +                             delete ref;
> +                     delete entryList;

But this is a bad way to do it. Much better is:

for (int32 i = entryList->CountItems() - 1; i >= 0; i—-)
        delete entryList>ItemAtFast(i);

I’ve explained this before: The other version stops at NULL items and therefore 
still leaks at least in theory. And it causes the list to constantly 
re-allocate so it has bad performance.

Best regards,
-Stephan


Other related posts: