[mythtv] [mythtv-commits] mythtv/master commit: 82226ea37 by Robert McNamara (rmcnamara)
Daniel Kristjansson
danielk at cuymedia.net
Sun Oct 30 14:59:13 UTC 2011
On Sun, 2011-10-30 at 14:17 +0000, MythTV wrote:
> Author: Robert McNamara <rmcnamara at mythtv.org>
> Services API: Fix GetUpcoming API.
>
> For some reason, the third item in was getting lost. I didn't exactly
> track down why that was happening, but by changing the iterator to match
> the one used in the scheduler, all items are present and accounted for.
The problem with the code you replaced is the index isn't adjusted after
the take() call.
The take call basically does a memcpy to move all the items after the
current item up one index. So the item following the current one that
would have had the index n+1 will have the index n after a take, but
in the loop we just skip it.
This means you are replacing an O(n^2) algorithm with a O(n) algorithm.
There is a problem however. You told tmpList not to auto-delete, but
it is a superset of recordingList which is set to auto-delete. Any
items in tmpList and not in recordingList will leak.
-- Daniel
More information about the mythtv-dev
mailing list