Re: if (blah) ...

From: Chris Proctor (
Date: 08/19/99

At 05:45  19/08/99 -0700, you wrote:
>"Daniel A. Koepke" wrote:
>> On Aug 18, Chris Proctor spake to the list:
>> > Can you then:
>> > free(blah);
>> > blah = NULL;
>> > if (blah) printf("This is still printed.\n");
>> > ?
>> Yes, you can, and, in fact, it's done throughout the CircleMUD code.
>> Several instances can be found just in the nanny() function.
>Really?  Could you please point out one single instance where this is
>done in nanny?  I looked and could not find even one of the "several"
>instances you mention.

Having had a look myself, and in relation to my question (which was really
"Is it safe to set a pointer equal to null after freeing it") dak is
certainly correct.
This was from bpl15 (didn't bother checking whatever archaic version I'm on).
Obviously it doesn't set the pointer equal to null and then do an if
(pointer) on it immediately (that'd be a bit silly, wouldn't it?).
Not sure exactly which bit you were referring to there . . .

from nanny(), in interpreter.c

        if (PLR_FLAGGED(d->character, PLR_DELETED)) {
          /* We get a false positive from the original deleted character. */
          d->character = NULL;

and a bit lower down:
    } else if (*arg == 'n' || *arg == 'N') {
      SEND_TO_Q("Okay, what IS it, then? ", d);
      d->character-> = NULL;

and again:
    case '2':
      if (d->character->player.description) {
        SEND_TO_Q("Old description:\r\n", d);
        SEND_TO_Q(d->character->player.description, d);
        d->character->player.description = NULL;


Chris Proctor
Chris Proctor, Technical Support
Labyrinth Connections Pty Ltd
Phone: +61 3 9642 4222 Fax: +61 3 9642 4955
Online Support Database:

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  |

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