[ Code ] Again... I still ahev problems with free() and NULL pointers

From: David Klasinc (bigwhale@CAPYBARA.SK-PTTSC.LJ.EDUS.SI)
Date: 08/04/97


Banzai!

Ok, I've done, what Sammy and George were suggesting and the result is,
that still, nothing is working.. *grumble*

Here's everything that goes with this thing:

db.c:
  #define FREE(ptr)       ({ free((ptr)); (ptr) = NULL; })

in free_char I've changet free's with FREE I was logging ptr and when it
was NULL I got nifty little message in mudlog... That pointer is free...
Nifty!

Then I have this in my check_fall() where I check if ch is falling and
since it's called every 2 seconds I've also put in few room spells that
are supposed to take hp from char...

void check_fall(void)
{
  int fall_dmg;
  struct char_data *ch, *next_ch;
  for (ch = character_list; ch; ch = next_ch) {
    next_ch = ch->next;

  if (ROOM_AFFECTED(IN_ROOM(ch), RAFF_ACID_RAIN))
    gen_damage(ch, GET_MAX_HIT(ch) * 10 / 100, SPELL_ACID_RAIN);

    if (ch && ((SECT(IN_ROOM(ch)) == SECT_FLYING)) && (!AFF_FLAGGED(ch, AFF_FLY
        !(IS_NPC(ch) && MOB_FLAGGED(ch, MOB_WINGS)) &&
        !(IS_NPC(ch) && MOB_FLAGGED(ch, MOB_NOACT)) &&
        !(GET_LEVEL(ch) > LVL_IMMORT)) {

... etc etc etc ...

gen_damage is a function for making generic damage on ch, where there is
no ch/victim relation.... imho  damage(ch, ch... sucks... ch get's exp if
killed by this damage() :))

Then there are usual checks, for the falling... as goes... first we check
if ch is there... remember, we got in a syslog, that ch was set to NULL
and that everything should work... Then we check if there is air in the
room, if ch is maybe affected by flying, is this a mob with wings? and no
act mobs (these are my dummy mobs, that just sit there with mobprogs
hooked on them) and if ch is maybe immortal... Ok.. and mud crashes
here...

Char get's extracted in gen_damage()

This is the backtrace:

#0  0x807ee85 in check_fall () at limits.c:367
#1  0x804f241 in heartbeat (pulse=160) at comm.c:691
#2  0x804f1ca in game_loop (mother_desc=3) at comm.c:671
#3  0x804e7f4 in init_game (port=4000) at comm.c:248
#4  0x804e780 in main (argc=1, argv=0xbffffb80) at comm.c:218
#5  0x804940b in ___crt_dummy__ ()

(gdb) print ch
$4 = (struct char_data *) 0x829bc08

*blink*

(gdb) print ch->player.name
$6 = 0x81ff3b8 "Puff dragon fractal"

*blink*

(gdb) print *ch
... snip snip snip ...
*blink*

Whaaaa?! Is this like it should be?!?! Now I'm puzzled...
it sure looks like, that I'm doing something wrong... I just can't figure
it out... :/ *grumble* *mega grumble*

Please, advise...

David!


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST