> extract_char(ch)... in there it calls free_char(ch), which SHOULD free all > memory used by a char, right? Then it frees the ch itself with free(ch) then > ch = NULL; right? Nope. > SO when it returns from free_char, ch SHOUDL = NULL, right? Nope. > SO when it returns from extract_char, ch should be null, right? Nope. All it does is call free(ch); it does not set ch equal to NULL. ch becomes a "dangling pointer"; i.e. a pointer that points to unallocated memory. This is correct behavior as long as that pointer is never used again. > while (ch->affected) > affect_remove(ch, ch->affected); > > free(ch); > ch = NULL; > } > > Those last 2 lines should kill the char outta memory, even if it leaves the > strings and such, right? Well.. I dunno... any help appreiciated. That code is a mistake! You must have added that "ch = NULL" to free_char() yourself because the last statement in the stock db.c's free_char() is simply "free(ch)". ch is a parameter passed to free_char(). Since C is call-by-value, and not call-by-reference, setting ch = NULL within free_char() does *NOT* mean that the value of ch is changed in free_char()'s caller. -Jeremy
This archive was generated by hypermail 2b30 : 12/18/00 PST