ah, thanks for the tip and the explanation, the clears things up a bit for me:D, however my problem still persists, i did a little change in where the log is, and as obviously expected it changed the output a bit, heres the code:

void do_wtcorrect(CHAR_DATA *ch, char *argument)
{
        int points;
        int length;
        char announce[MAX_INPUT_LENGTH];
        char log_buf[MAX_STRING_LENGTH];
        DESCRIPTOR_DATA *d;

        if ( is_exact_name(argument,wordtwist.word) )
                return;
        strcat(wordtwist.word," ");
        strcat(wordtwist.name," ");
        strcat(wordtwist.word,argument);
        sprintf(log_buf,"%s",wordtwist.word);
        strcat(wordtwist.name,ch->name);
        log_string(log_buf);

and the log would look something like this if a person guessed nasal, naval, nemeral(assume thats a word lol):
nasal
Namenasal naval
Namenasal NameNaval nemeral

etc

i put in this free_string()'s, but im assuming this has something to do with my wordtwist_data structure because it keeps adding them together if theyre in the same structure, i think. im going to post my structure and everything that has to do with it and hopefully if ive gone wrong somewhere someone can point it out to me:

in merc.h:
struct  wordtwist_data
{
        int turns_left;
        char *first;
        char *last;
        char dict[MAX_STRING_LENGTH];
        char *word;
        char *name;
        bool newround;
};

typedef struct  wordtwist_data  WORDTWIST;

extern          WORDTWIST               wordtwist;

db.c:
WORDTWIST               wordtwist;


did i go wrong anywhere here that could be causing this problem with wordtwist.word and wordtwist.name


From: "Richard Lindsey" <[EMAIL PROTECTED]>
To: "Tristan M" <[EMAIL PROTECTED]>, <[email protected]>
Subject: RE: a problem with checking if a word has been entered already
Date: Sun, 22 Aug 2004 14:40:51 -0500

ok, well one thing i saw that could use a little tweaking in your newly posted function is a memory leak i see, which is probably why it's trampling into your users' space and showing by their prompt and in their prefix...

Where this is:

wordtwist.word = str_dup( "" );
wordtwist.name = str_dup( "" );

make sure that before you str_dup those you free_string them first, here's what happens:

the first time they're initialized in the code, they'll get a set of addresses, say 1300 and 2300 for instance... after adding words to them and then completing one round, they may be say... 100 char's long each, ending at 1400 and 2400 respectively... then you set the pointers to the beginning of that memory space = to str_dup( "" ), which basically puts an empty string into a new spot of memory, say 3300, and returns that address to wordtwist.word, and another one at 4300 to wordtwist.name, and the 200 memory spaces that were allocated to the previous strings are then lost and can't be reused until the mud process dies and that space is freed to the OS... leaks like that can inadvertently trample onto other sections of memory...

so anyway, i had a problem like this just a while back, if you go search the archives for something along the lines of "argument corrupted in transit", and it was due to a memory leak... try patching that and see if it helps any, if not we can always explore other options :)

wavewave
Richard Lindsey.
D&j)b       bN2&!0܂&Ybا~

_________________________________________________________________
Take advantage of powerful junk e-mail filters built on patented Microsoft® SmartScreen Technology. http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN® Premium right now and get the first two months FREE*.


Reply via email to