void affect_remove(struct char_data * ch, struct affected_type * af)
{
struct affected_type *temp;
assert(ch->affected);
affect_modify(ch, af->location, af->modifier, af->bitvector, FALSE);
REMOVE_FROM_LIST(af, ch->affected, next);
free(af); /* <------------ here... */
affect_total(ch);
}
/* Call affect_remove with every spell of spelltype "skill" */
void affect_from_char(struct char_data * ch, sh_int type)
{
struct affected_type *hjp; /* <----- actually frees this? */
for (hjp = ch->affected; hjp; hjp = hjp->next)
if (hjp->type == type)
affect_remove(ch, hjp); /* <------- when this is called? */
}
howdu, well its late and i may be seeing things blurry (so get yer flamin
fingers ready :P)
when i call affect_remove like that directly above (btw this is stock3)
im sending the block allocated hjp ptr to the function affect_remove...
now since C is call by value a copy of the PTR is made which is called
( af ) in the function affect_remove... so im not destroying the ptr
itself, thats not a problem...
now after we remove the modifiers and such in that function
we free af, which deallocates the memory associated with af, which in reality
deallocates the memory associated with hjp from the calling function...
am i right? does it free this type of memory, this type being a declared
type upon entry to the function block, OR does it realize its
not a malloced piece and leave it alone?
because ive been having some crashes every once in a while and it bombs
on this line
for (hjp = ch->affected; hjp; hjp = hjp->next)
if (hjp->type == type) /* <------ here */
which doesnt make sense because if hjp is NULL it wont go in there
so it's not NULL, so the only explanation i can see is that hjp may not
be NULL, but it may be pointing to a freed address from some time before
so thats my question basically, should we in fact be freeing (af) ? when
it's a local variable in the previous function which called it
any help or insight to what i may be missing would be much appreciated
:)
jtrhone
aka
vall
RoA
This archive was generated by hypermail 2b30 : 12/18/00 PST