RE: [GD-Windows] new/delete across DLL's
Brought to you by:
vexxed72
From: Jon W. <hp...@mi...> - 2003-03-24 20:07:24
|
> Just to be clear, you're saying this is bad: >=20 > foo *f =3D Foo::newFoo(); > delete f; Yes. Unless operator new/delete are overridden in Foo, but=20 evenso, there's other problems you'll run into. > but that this is good: >=20 > foo *f =3D Foo::newFoo(); > Foo::deleteFoo(f); Yes. I'd prefer something like: Foo * f =3D gFooFactory->newFoo(); f->release(); > >Un-balanced allocations/deletions really are a bad idea for a > >variety of reasons; this being just one. >=20 > Well, a big part of me pretty much blames the language, but that's a=20 > bit too convenient given that Microsoft's DLL idiosyncracies seem to=20 > be rather unique in the world of operating systems (although you do=20 > point out some interesting cases on Unix). Actually, AIX, MacOS and Windows all have the "sealed container"=20 linkage model, and most other UNIX-es have the "merged global symbol=20 table" model. I like "sealed container" because it makes it possible=20 for me to prove that I tested in the same environment that I will=20 run. (Don't know about MacOS X though -- maybe they went over to the=20 dark side with their new linkage model) Cheers, / h+ |