Add the lines with the + at the begining.

void free_charged_data(CHARGED_DATA *attack)
{
+            if(!attack)
+                 return;
            attack->next = charged_free;
            charged_free = attack;
}

That'll make sure you don't pass a null pointer through the free_charged_data.

Davion



From: "sarix" <[EMAIL PROTECTED]>
To: "ROM" <[email protected]>
Subject: pointer == 0x20?
Date: Sat, 8 Mar 2003 15:14:51 -0700

 Hey list,

I'm having a small problem with a link list of mine. And the problem is, the
points some how are coming up with a weird value. I'm not all that great
memory or hex, and I was wondering
if some of you could point me in the right Direction of how I could fix up
this problem. In GDB this is what the core is looking like:

#0  0x08186280 in free_charged_data (attack=0x20) at recycle.cc:1355
1355            attack->next = charged_free;
(gdb) list
1350    }
1351
1352
1353    void free_charged_data(CHARGED_DATA *attack)
1354    {
1355            attack->next = charged_free;
1356            charged_free = attack;
1357    }
 Here's how I allocate and handle the pointers for it:

 CHARGED_DATA *charged_free;

 CHARGED_DATA *new_charged_data()
{
            CHARGED_DATA attack_zero;
           CHARGED_DATA *attack;

             if ( !charged_free )
                        attack = new CHARGED_DATA;
            else
            {
                        attack = charged_free;
                        charged_free = charged_free->next;
            }

            *attack = attack_zero;
            return attack;
}
void free_charged_data(CHARGED_DATA *attack)
{
            attack->next = charged_free;
            charged_free = attack;
}

I don't get why the points value is coming back as 0x20, and all the times
it's crashed us. The pointer has always had that same value. Any help,
ideas, or insight on how I could go about fixing this would be deeply
appreciated


--
ROM mailing list
[email protected]
http://www.rom.org/cgi-bin/mailman/listinfo/rom


_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE* http://join.msn.com/?page=features/junkmail


Reply via email to