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

List:       kde-devel
Subject:    Re: free instead of destructor
From:       Roberto Alsina <ralsina () unl ! edu ! ar>
Date:       2000-02-07 10:36:17
[Download RAW message or body]

On Mon, 7 Feb 2000, Michael Koch wrote:

> Am Mon, 07 Feb 2000 schrieb Roberto Alsina:
> > On Mon, 7 Feb 2000, Marcos Dione wrote:
> > 
> > > 
> > > 
> > > On Mon, 7 Feb 2000, Roberto Alsina wrote:
> > > 
> > > > On Mon, 7 Feb 2000, Marcos Dione wrote:
> > > > 
> > > > I don't get it.
> > > > 
> > > > If the object is a null pointer, obj->free() will still segfault.
> > > 
> > > 	mmm... I think that the way Dephi does it is a static class
> > > member... guessing too much?
> > 
> > Ok, QObject::free(myobj) would indeed work.
> > Although I have no idea on how that method could check that the pointer is
> > valid, considering that delete 0 is a perfectly valid noop :-)
> 
> IMO we have no real chance to make this in C++. This free feature like it is in
> Delphi needs language support. AFAIK free is standard Delphi language and
> created automaticly by compiler if not explicitly written in the sources, like
> the copy constructor in C++.

Well, it actually can be done. We need to overload the new operator to
keep something like a dictionary of all QObjects, and overload delete to
remove them from there and do the actual deleting.

But doing this just for QObjects is kinda useless. I'd say just use
something like ccmalloc while debugging, and then give the users programs
that don't have hacks of this magnitude ;-)

> I love this cat, or whatever it is ;-)

I think it's a cat, although I should ask the author :-)

 ("\''/").__..-''"`-. .         Roberto Alsina
 `9_ 9  )   `-. (    ).`-._.`)  ralsina@unl.edu.ar
 (_Y_.)' ._   ) `._`.  " -.-'   Centro de Telematica
  _..`-'_..-_/ /-'_.'           Universidad Nacional del Litoral
(l)-'' ((i).' ((!.'             Santa Fe - Argentina
                                KDE Developer (MFCH)
The stone age didn't end for a lack of stone" Firoz Rasul

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

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