Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Entire forum
➜ SMAUG
➜ Compiling the server
➜ Log: STRFREE called on str_dup pointer:
Log: STRFREE called on str_dup pointer:
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Robert Powell
Australia (367 posts) Bio
|
Date
| Wed 11 Jun 2014 11:03 AM (UTC) |
Message
| Log: STRFREE called on str_dup pointer: quest.c, line 961
In mud.h pcdata
const char * questarea; /* Questmaster */
const char * questroom; /* Questmaster */
In quest.c update function
if ( ch->pcdata->questroom )
STRFREE ( ch->pcdata->questroom );
if ( ch->pcdata->questarea )
STRFREE ( ch->pcdata->questarea );
Can anyone tell me what is going on here, |
Just a guy having a bit of fun. Nothing more, nothing less, I do not need I WIN to feel validated. | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #1 on Wed 11 Jun 2014 08:12 PM (UTC) |
Message
| Judging by the source, if you call str_alloc (STRALLOC) to duplicate a string you must call DISPOSE to get rid of it, and not STRFREE.
See this comment at the start of hashstr.c:
/****************************************************************************
* Advanced string hashing functions (c)1996 D.S.D. Software, written by *
* Derek Snider for use in SMAUG. *
* *
* These functions keep track of how many "links" are pointing to the *
* memory allocated, and will free the memory if all the links are removed. *
* Make absolutely sure you do not mix use of strdup and free with these *
* functions, or nasty stuff will happen! *
* Most occurances of strdup/str_dup should be replaced with str_alloc, and *
* any free/DISPOSE used on the same pointer should be replaced with *
* str_free. If a function uses strdup for temporary use... it is best if *
* it is left as is. Just don't get usage mixed up between conventions. *
* The hashstr_data size is 8 bytes of overhead. Don't be concerned about *
* this as you still save lots of space on duplicate strings. -Thoric *
****************************************************************************/
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Robert Powell
Australia (367 posts) Bio
|
Date
| Reply #2 on Wed 11 Jun 2014 09:18 PM (UTC) |
Message
| I did try dispose but that also came back with a BUG similar to the other one. So i know there is something wrong somewhere.
DISPOSE called on STRALLOC pointer:
I went looking for where questarea and questroom are given any value and this is the first instance of it that I can find,
ch->pcdata->questroom = room->area->name;
ch->pcdata->questarea = room->name;
So both DISPOSE and STRFREE think that the other guy should be doing the cleaning up.
So what I am guessing I need to do is the following so that the string has been allocated correctly and then the macro will clean things up properly without issuing the bug.
ch->pcdata->questroom = STRALLOC ( room->area->name);
|
Just a guy having a bit of fun. Nothing more, nothing less, I do not need I WIN to feel validated. | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #3 on Thu 12 Jun 2014 04:09 AM (UTC) |
Message
|
Quote:
ch->pcdata->questroom = room->area->name;
ch->pcdata->questarea = room->name;
That is just copying the pointer, which is probably not a good idea. Certainly if you just copy the pointer you shouldn't dispose of it at all (you don't "own" it).
Probably you should str_dup it (duplicate the string) and then you own the copy. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
15,710 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top