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