[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: free instead of destructor
From:       Bo Thorsen <gobo () imada ! sdu ! dk>
Date:       2000-02-08 10:00:06
[Download RAW message or body]

On Mon, 7 Feb 2000, Malte Starostik wrote:

> Marcos Dione wrote:
> 
> >         inteligent? delete ain't "inteligent". try to delete a
> > non-allocated object and you'll finish with a SIGSEGV.
> 
> If you define non-allocated as a NULL pointer, what I interpreted your sentence
> "destroys the object if and only if the object is allocated (is not a null
> pointer)"
> It won't segfault. A delete myobj with myobj == NULL will do just nothing. If
> it's an invalid non-NULL pointer, your lost with Free either.

I would any day argue that it stems from bad design not to be able to both
allocate an object on the heap and on the stack. But I have not followed
the discussion about this and therefore I don't know what made you all
agree that it is all right to impose this restriction. Could someone
enlighten me? (I'm not trying to reopen a debate; I just really want to
know).

But if it is necessary, why not just declare the new or delete operator
private? This way you at least get a compile time error and a bunch of
"why the he..." messages on kde-devel.

--

Bo Thorsen
gobo@imada.sdu.dk
Lahnsgade 31, st.
DK-5000 Odense C
Tlf: +45 66 11 83 85

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic