Re: [CODE]Strange gdb behaviour - passing bad pointers.

From: Mike Breuer (mbreuer@new.rr.com)
Date: 07/19/01


----- Original Message -----
From: "Welcor" <welcor@DUNE.NET>


> <gdb output>
> #0  guild_teaches (guild=0x4cb7e88, skill_num=1) at guild.c:241
> 241         if (skill->skillnum == skill_num)
> (gdb) print guild
> $8 = (struct guild_master_data *) 0x18
> </gdb output>
>
> <relevant code>
> int guild_teaches(struct guild_master_data *guild, int skill_num) {
>   struct train_info *skill;
>
>   for (skill = G_SKILLS(guild);skill;skill = skill->next)
>     if (skill->skillnum == skill_num)
>       return (1);
>
>   return (0);
> }
> </relevant code>

You don't supply the definition, but I assume G_SKILLS is something like this:

#define G_SKILLS(g) ((g)->skills)

Assuming that is correct, The only reasonable explanation is that there is
something wrong with your skills linked list.  Are you remembering to
initialize it to 0?  Are you remembering to set the next pointer to 0 when you
add to the end of the list (including when you add the first element)?  Take a
look at the code that assembles your lists, the problem is obviously there.

Mike

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/06/01 PST