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.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ SMAUG
➜ SMAUG coding
➜ STRFREE/DISPOSE
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Greven
Canada (835 posts) Bio
|
Date
| Wed 14 Jan 2004 08:58 PM (UTC) |
Message
| Recently I've spent hours making sure that the STRALLOCs are consistant with the STFREE's, and the DISPOSE are consistan with str_dup. But I keep thinking that there has to be an easier way to do this. The best I can think is identifying if a string has links on it(ptr->links), but to do that I think you would need to be able to identify what kind of info is being passed.
I've also heard that c++ might make it possible to stop mis-matched functions, and since I've recently converted, that would be quite handy, heh. Any ideas? |
Nobody ever expects the spanish inquisition!
darkwarriors.net:4848
http://darkwarriors.net | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #1 on Wed 14 Jan 2004 11:01 PM (UTC) |
Message
| To make it error-proof you would need to have two separate data types.
For example a standard string (str_dup version) could be a pointer to a char* - just like it's supposed to be.
The hashed string (STRALLOC) on the other hand could be a pointer to a structure, like so:
struct HashedString
{
char* str;
};
So you're just adding one level of code to it. Instead of doing ch->name, you'd do ch->name.str or something like that.
The cleanest way to do it however would probably be to migrate all the way to C++ style strings (STL) and make your own class for hashed strings. That's how I did it, in any case. :) And I find it to be oh-so-much nicer. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | 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.
5,742 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top