coding problem with a character creation addition (mem leak?)

Sorren@usa.net
Date: 09/16/97


in structs.h I have added a pointer to my char_creation routine, it IS at
the top of descriptor data.

struct current_table {
        int nuyen;
        byte skill_pts;
        byte attrib_pts;
        bool magic; /* 0 not set 1 no magic 2 magic */
        byte magic_pts;
        bool race; /* 0 not set, 2 metahuman 1 human */
};

struct char_creation {
  struct current_table stats[6];
  byte priority;
};

struct descriptor_data {
struct char_creation *create;  /* this added to descriptor data */
...
};

In interpreter.c in my nanny() I added

 if (d->character == NULL) {
     CREATE(d->character, struct char_data, 1);
     clear_char(d->character);
     CREATE(d->character->player_specials, struct player_special_data, 1);
          if (d->create == NULL) {
                 CREATE(d->create, struct char_creation, 1);
                 memset((char *) d->create, 0, sizeof(struct
char_creation));
         }
     d->character->desc = d;
   }

right after I use the creation table I do a

if (d->create) free(d->create);

Also, just for safety, in comm.c I added to close_socket
if (d->create) free(d->create);

Now, When I try to use this code my mud crashes on a MALLOC failure, it
says it can't allocated memory, but if I comment out all relevent portions
of this code the mud runs fine.  I could manage to scrounge up a
a core dump, but it doesn't give a line or any .c file for a reference,
just a malloc failure.  Perhaps someone could see something I might have
overlooked ?

Sorren


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