Re: strdup or str_dup?

From: Patrick Dughi (
Date: 03/08/99

> > strdup or str_dup? Which one should I use and why?
> strdup() may not be as portable.  str_dup() is part of stock circle
> because strdup() is not available on all compilers.
        Of course, str_dup is a case-insensitive match if I remember
(though it can easily be altered), and strdup is not.  I'd say use str_dup
though, as it's a good function to throw in a little bit of saftey
checking, in case more than just yourself is working on the code.

        Alot of my commonly used and misused utility functions have checks
in them to guarentee that their arguments are valid (usually just
non-null).  Saves me a lot of hassle down the road.

Also in the news:
        Had an odd problem lately.. Had a spec proc set on a creature
where if it was not currently charmed, or did not have a master, it would
extract itself.  It was not my code, and was poorly done so I don't feel
bad bringing it up, but the curious part was the result.  Basically, the
next mob-activity tick after the above conditions for extraction were met,
the mud would crash on the mob-prog random percent check.  I'd look at the
core and see that it tried to access mob_index[mob->nr]  where, since mob
should have been extracted and freed, mob->nr was > top_of_mobt (well
i'd have thought it to be random, but it was always the same large

        Now, extract character should take care of the entry in the
mob_index, and having been removed from the character list, the mob
structure itself should not have been accessable.  The extract_char() is
as close to stock as allows me to say it is functioning as it ought to.

        Any ideas on this one?  I ended up 'fixing' it by teleporting the
mob to a mob-only unaccessable room and having another mob purge them, but
I'm really curious as to why it did not work in the first place, in the
way it was intended. Is it just bad form to call extract_char from within
a spec_proc when you target yourself?

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  |

This archive was generated by hypermail 2b30 : 12/15/00 PST