At 09:43 AM 3/10/99 -0800, you wrote:
>On Wed, 10 Mar 1999, Acido wrote:
>
>>But if staying up could mean corrupt data in eg. pfiles (can't remember in
>>my head of save_char() calls str_dup() right now though.. it would be a
>>pretty bad thing to stay up i figure.
>
>I'm sure a NULL pointer str_dup is the least to worry about of what most
>coders put into their MUDs. Even stock CircleMUD has had about 3 memory
>corruptions fixed since bpl12.
true
>
>A NULL pointer str_dup() comes up so often in OasisOLC that it has its own
>function now, str_udup().
>
>char *str_udup(const char *txt)
>{
> return str_dup((txt && *txt) ? txt : "undefined");
>}
>
>Because in OLC, the builder could leave a NULL pointer and some people
>write MUD code that doesn't like NULL pointers.
>
Why not throw the same check in str_dup() to avoid the extra function??
char *str_dup(const char *source)
{
char *new;
if (!*source)
return ("undefined"):
CREATE(new, char, strlen(source) + 1);
return (strcpy(new, source));
}
or would this be a bad thing to do??
+------------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
+------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST