eero.tamminen at netsonic.fi
Thu Dec 30 13:51:39 EST 2004
I'll CC these to the list, these might interest others too.
> I added a check for double calls to refcount() on the same object,
> if REFCOUNT_DEBUG is defined. It found a bug in bird.c where you use
> refcount(). Actually all sprites are automatically
> refcounted, so you never have to use refcount() when dealing with
> them, only ref() and deref().
Ok. I removed the refcounting from bird and added an option for the
debugging to the Makefile (on by default).
> > Btw. why deref() always returns zero, didn't the
> > earlier sprite_release return the refenced object if something was
> > still referencing it and the sprite was still alive?
> Yes, I now like the "ideom"
> p = deref(p);
> to dereference *p. Then deref should always return 0, so that we know
> that p is no longer a valid pointer. Anyway if we release the reference
> we should not try to access the object any more.
> > There's one strange thing in bonus.c:
> > - You changed sprite_kill(s) to refkill(s) and when I looked into
> > sprite_kill() function, that indeed only calls refkill(). My
> > question is: - Does sprite now get the MSG_KILL always when it's
> > destroyed?
> It should send MSG_KILL indeed. I wonder if it does though.. I don't
> have the code on this machine, but I will check.
sprite_kill() doesn't do anything else except refkill(). refkill() doesn't
know anything about sprites...
> > The reason why I ask is that the sprite should deref the referenced
> > sprite before dying... See bonus_free() and bonus_sigget() in the
> > new sprites/bonus.c.
> Yes, you are right.
Do you mean that the sprite_kill function would be removed from the sprite
struct and replaced with handling of the MSG_KILL function?
If sprite creation does refcount automatically, then killing sprite should
call deref (or refkill?) which also frees the sprite I think. I guess
MSG_KILL handler should then do that... If sprite has some extra allocations
it needs to free them before doing deref(), right?
More information about the airstrike