Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2003:
[Freeciv-Dev] Re: list cleaning
Home

[Freeciv-Dev] Re: list cleaning

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: "Per I. Mathisen" <per@xxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: list cleaning
From: Raimar Falke <i-freeciv-lists@xxxxxxxxxxxxx>
Date: Sun, 30 Nov 2003 14:23:22 +0100

On Sat, Nov 29, 2003 at 03:41:54PM +0000, Per I. Mathisen wrote:
> On Sat, 29 Nov 2003, Raimar Falke wrote:
> > > > There is another way. If this 'normalize' iterators are in place we
> > > > can ensure with assert that unlink isn't called when we are currently
> > > > iterating over the list. Such cases would then be replaced (by hand)
> > > > with safe iterations. This is the conservative approach: you can be
> > > > sure that there are no unsafe unlinks and there is a known and
> > > > constant memory and cpu-time usage.
> > >
> > > Not if deletions only happen in extremely rare cases. This does happen.
> >
> > Yes. However we will know that this happens.
> 
> Not if we don't catch it. Players test more code paths in the game than we
> do.

We catch it with the assert.

> > There is another safety with this approach: if there is a still
> > 'unnormalize' iterator the nesting count will remain >1. This will
> > cause the assertion to trigger even if the code was correctly
> > converted to use the safe version.
> 
> You mean, another way to generate a bug where there was none before.
> 
> Isn't it best not do this 'normalizing' (banning perfectly valid C) in
> iterators when we don't have to?

Look we have unsafe iterators (unlink during iterate). In the past we
used a safe version in the rare cases were we needed it. The safe
versions then were removed. So we can either revert the change and
reinstall the safe versions (this was rejected of reasons which may be
facts or not) or we replace it with something better. And better here
means for me that we build a safer version which always works. The
older code with the safe iterators had low runtime impact and used to
have low code impact.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
  The trick is to keep breathing.


[Prev in Thread] Current Thread [Next in Thread]