Re: unrefDelete and pfUnrefDelete

New Message Reply Date view Thread view Subject view Author view

From: Yair Kurzion (yair++at++polygon.engr.sgi.com)
Date: 05/25/2001 15:48:56


Hello Kevin !

> I've found a difference between C and C++ versions of the
> unref-delete functions in Performer 2.4:
> - pfUnrefDelete(pfGroup*)
> - pfGroup::unrefDelete().

pfUnrefDelete translates to pfBuffer::unrefDelete, not pfGroup::unrefDelete().
When you call pfGroup::unrefDelete, you inherit from pfMemory::unrefDelete.
These two are not the same.

pfBuffer::unrefDelete decrements the ref-count, if ref-count reaches zero it
end up calling pfGroup::checkDelete on your pfGroup node. From the pfMemory
man page:

     pfMemory::checkDelete frees the memory associated with the object if its
     reference count is <= 0. When an object is freed, it decrements the
     reference count of all pfMemories that it once referenced and will delete
     any of these pfMemories with reference counts that are <= 0. Thus,
     pfBuffer::checkDelete will follow all reference chains until it
     encounters a pfMemory which it cannot delete. Note that the reference
     count of a pfNode is incremented each time it is added as a child to a
     pfGroup. Thus, a pfNode must be removed from all its parents before it
     can be deleted.

Calling pfMemory::unrefDelete (or pfGroup::unrefDelete) decrements the ref
counts, and if reached zero calls ``delete'' on your object.

I agree that this choice of API names is quite poor.
-yair

> In the man page, the descriptions for the two versions are identical, but
> the actual behavior is different. (a possible bug in performer?)
>
> Here is the symptom:
>
> - pfUnrefDelete(pfGroup*) decrements the refcount of the given
> group and all child refcounts.
>
> - pfGroup::unrefDelete() decrements the refcount of the given
> group BUT DOES NOT decrement the child refcounts.
>
> Why would these two functions behave differently? If this isn't a bug, I
> would really appreciate if someone could help me understand.
>
>
> See my test code below followed by its output:
>
> ++at++--++at++---++at++---++at++----++at++-----++at++------++at++------++at++-----++at++----++at++---++at++---++at++--++at++
> Kevin Meinert __ _ __
> http://www.vrac.iastate.edu/~kevn \ || \| \ / `
> Virtual Reality Applications Center \ ||.-'|--\
> Howe Hall, Iowa State University, Ames Iowa \|| \| \`__,
> -----------------------------------------------------------

-- 
\_________  \_____  \__    \__  \_____         Yair Kurzion
\_________  \_____   \__   \__  \_____         yair++at++sgi.com
       \__     \__   \____\__      \__   http://reality.sgi.com/yair
       \__          \__  \__                Work: (650) 933-6502
       \__          \__   \__               Home: (408) 226-9771
       \__          \__    \__             


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Fri May 25 2001 - 15:48:59 PDT

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