str_dup, CREATE(), et al

From: Akuma/Chris Baggett/DOOMer (doomer@BAYOU.COM)
Date: 03/15/98


ok, my mud was running fine until I decided to be memory correct.

what i've done is convert load_char() to accept
char_data structure instead of char_file_u (thus eliminating them).
but a problem i had was that load_char required char_data to already
but allocated before anything could be done.

well, when it comes around to using the players command in the mud
(where it loops all the way through loading each char as it goes and
 freeing it later)
it would SIGSEGV (Seg Fault) in the libmalloc library. (after a CREATE() call)
i have a loop like this

struct char_data *tch;
for (i = 0; i <= top_of_ptable; i++) {
   CREATE(tch, struct char_data, 1);
   if (load_char((player_table+i)->name, tch) < 0) {
      FREE(tch); continue;
      }
   else do the stuff with char.
   if (tch) free_char(tch);
   }

well, anyway, the only way I could get around this error at this time
is just to put ONE CREATE at the top, and not free it until the end
(i know this is a MAJOR memory leak, but I haven't got time for
 a work around right now, maybe later tonite).

anyway, I was wondering if there is a better way to do this?

I would like to not have any memory leaks, but i'd also like to be
able to run my mud :-)

I think it kept running out of memory or something ( i don't know why )
(i could have memory leaks out the rear and not crash, but when
 i try to be memory correct, it kills me)

anyway, is there something I could do to work-around this?
or just live with memory leaks?

Thanks.

Code On
Akuma the Raging Coder

  +------------------------------------------------------------+
  | "The poets talk about love, but what I talk about is DOOM, |
  |      because in the end, DOOM is all that counts." -       |
  |   Alex Machine/George Stark/Stephen King, The Dark Half    |
  |        "Nothing is IMPOSSIBLE, Just IMPROBABLE"            |
  |   "Easier Said Than Done, But Better Done Than Said..."    |
  +------------------------------------------------------------+


     +------------------------------------------------------------+
     | 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/15/00 PST