To leak or Not to leak

New Message Reply Date view Thread view Subject view Author view

From: Larry Ramey (ramey++at++vrco.com)
Date: 08/23/2001 11:55:15


I'm unsure if this is going to leak or not.....

pfTexGen* texGen = new pfTexGen;
assert(texGen);
gState->setMode(PFSTATE_ENTEXGEN,PF_ON);
gState->setAttr(PFSTATE_TEXGEN,texGen);

What if the gState already HAD a pfTexGen? I know pfTexGen is a pfMemory object so
it has reference counting, but is smart enough to know it is no longer needed, or do
I have to give it kick in the head with unRef();

And just for curiosity what would happen if I used

ptr = gState->getAttr(PFSTATE_TEXGEN);
pfDelete(ptr);

the pfTexGen is STILL referenced by the gState.

I've read the man page and I'm starting to think I should get the old pfTexGen, put
the new one in, then pfCheckDelete() on the old one.

If that is the correct solution, what happens when I call

ptr = gState->getAttr(PFSTATE_TEXGEN);

on a GeoState that never had a pfTexGen applied to it? Do I get a NULL pointer?

Thanks guys.

--
"And I won't waste my time fitting in/
Because I don't think contrast is sin" -MillenColen
Larry E. Ramey
Software Engineer
ramey++at++vrco.com


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Thu Aug 23 2001 - 11:55:31 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.