Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[vdr] Re: [PATCH] vdr-subtitles modeChange crash
Thanks for this patch. It seems to solve my YLE crashes too!
-tomi
Mws wrote:
On Tuesday 25 January 2005 19:43, Ville Skyttä wrote:
vdr-subtitles-map-iter.patch
hi,
attached find my version of the map iterator problem;
Ville, yes you were on the right way - but some comments.
std::map behaves a bit different if you use it like it is used in this case of
(god may forgive me) <bad indented>
code.
if you erase a member of the map - the keymap is rehashed.
but in this case we just want to get rid of all entries in my understanding.
result:
just iterate from begin() to end() and delete i->second;
this will delete correctly the saved entries;
afterwards - if we reached the end - just clear() the map to have also the
keyentries removed.
this is save, common use and fast.
next thing is to pre increment the iterator
a postincrement is more time consuming cause the old value is stored temporarely
then the iterator is increased
then the stored value is returned
preincrement is just iterator increase and return
i know that these things are not that role-playing on your 3.x GHz machines, but if you use
processors about 66 to 300 mhz you'll notice the difference.
regards
mws
------------------------------------------------------------------------
--- dec.c.orig 2005-01-25 21:47:59.458405288 +0100
+++ dec.c 2005-01-25 21:52:13.104073152 +0100
@@ -557,31 +557,27 @@
for (RegionMap::iterator i = iRegions.begin();
i != iRegions.end();
- i++)
+ ++i)
{
- Region* region = i->second;
- iRegions.erase(i);
- delete region;
+ delete i->second;
}
+ iRegions.clear();
for (ObjectMap::iterator i = iObjects.begin();
i != iObjects.end();
- i++)
+ ++i)
{
- Object* object = i->second;
- iObjects.erase(i);
- delete object;
+ delete i->second;
}
-
+ iObjects.clear();
for (ClutMap::iterator i = iCluts.begin();
i != iCluts.end();
- i++)
+ ++i)
{
- Clut* clut = i->second;
- iCluts.erase(i);
- delete clut;
+ delete i->second;
}
+ iCluts.clear();
}
void cDecoder::acqPoint()
@@ -620,4 +616,4 @@
}
reset();
}
-
+
Home |
Main Index |
Thread Index