Re: [code] quick question.

From: Franco Gasperino (awe@CET.COM)
Date: 11/07/97


There is a beautiful debug library that i use all the time that is standard
on all installs (or should be). Include this header in your .c file:

#include <assert.h>

and then do a:

assert(<condition to check>);

for example:

for (tch = world[ch->in_room].people; tch; tch = next_tch)
{
  next_tch = tch->next_in_room;

  assert(tch != NULL);

  do some crap to tch...

}

and if tch is NULL, it will throw an assertion, telling you the line number
and which file.
Its similar to printfs but is a bit more savy.

  Franco Gasperino
  Cutting Edge Communications
  509-444-INET
  http://www.cet.com/
  awe@cet.com


----------
> From: Desmond Daignault <tekdd@DTOL.DATATIMES.COM>
> To: CIRCLE@post.queensu.ca
> Subject:  [code] quick question.
> Date: Friday, November 07, 1997 10:51 AM
>
> I have a function that scrolls through all of the mobs/players in a room
> that keeps breaking when doing a tch->next_in_room;
>
> The core file and purify both indicate a memory segment violation.  is
> there a way to detect a possible memory segment violation and prevent it?
>
> The tch pointer seems to be a valid pointer. and when i play computer
> using gdb, the world[ch->in_room].people->next_in_room->next_in_room...
> works fine all the way to the last player/mob in the room which shows
NULL
> as the next_in_room.
>
> the for statement used is:
> for(tch = world[ch->in_room].people;tch; tch = next_tch)
> and it dies doing:
>   next_tch = tch->next_in_room;
>
> *shrug*
>
> --
>
> Dez.
>
> void signature () {
>   printf ("Praise not the day until evening has come; a woman\n"
>           "until she is burnt; a sword until it is tried; a maiden
until\n"
>           "she is married; ice until it has been  crossed; beer until
it\n"
>           "has been drunk.   -- Viking Proverb\n");
> }
>
>
>      +------------------------------------------------------------+
>      | Ensure that you have read the CircleMUD Mailing List FAQ:  |
>      | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
>      +------------------------------------------------------------+


     +------------------------------------------------------------+
     | 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