Re: Signal memory leak.



> 
> In C (and in C++ w/o MI), you can just pass and cast
> pointers w/o their values being changed, even if the cast
> is fully invalid.  For example:

Definitely don't try this one any C++ object.  Even without MI the
pointer maybe different.  For example, on VC++ (an M$ product) the
following casting will generate unexpected results. 

class Foo 
{ 
  int i;
};

class Bar: public Foo
{
  int j;
  virtual ~Bar () {};
  virtual void hello() {};
}

Bar *b=new Bar();
cout << "Bar b is at " << (void*)b <<endl;
cout << "Foo b is at " << (void*)((Foo* b)) <<endl;

This alone should be enough to render that function utterly 
dangerous on any C++ compiler.  It is undefined behavior.
Thus compiling code of this nature though a C++ compiler 
will break on what seems like valid code on others.

(Trust me, I learned this one the hard way.)


> Both behaviors are desirable and fashionable :),
> IMHO the function's name is the problem.
> It should be `gtk_object_connect_swapped' or `gtk_object_connect_other'
> and take a gpointer.

Definitely agree.  It is useful in some cases, but the bad casting
should be removed.  gtk_object_connect_other seems more appropriate.

--Karl



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