pingus-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cleanup patch / design rules


From: David Philippi
Subject: Re: cleanup patch / design rules
Date: Sat, 24 Aug 2002 21:22:16 +0200
User-agent: KMail/1.4.1

On Friday 23 August 2002 23:42, Ingo Ruhnke wrote:

> We have quite a few classes that hold reference pointers to other
> objects, so just deleting them will not do any good. But we should
> probally name these pointers differently or make them via some kind of
> smartpointer undeletable or something like that.

If I guess right, those are only for caching purposes? 
How about using a reference instead? Change

foo* bar = get_pointer() into foo& bar = *get_pointer()

and there's no risk that anyone will ever try to delete it.
The only problem that remains is that a reference must be always initialized, 
so if the cache variable isn't initialized in the constructor anyway, we 
need a dummy. Something like namespace { foo baz; } at the beginning of the 
.cxx would be enough, since you can now initialize every foo& to baz.

Bye David





reply via email to

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