Re: strdup or str_dup?

From: Daniel A. Koepke (
Date: 03/09/99

Acido wrote:

> Uhm so i get the idea it's a pretty bad thing if it dosn't crash in
> most cases. So how do i make sure that it DO crash and dump core
> acordingly??

Well, it should already.  I don't have the code at hand, but it should
call "strlen()" to determine the number of bytes to allocate for the
new string.  strlen() should crash on NULL.  Although, unfortunately
and oddly enough, some platforms don't crash when they should, or
do crash when they shouldn't.

I remember working for a MUD that was running on Solaris a few years
back -- I wrote up some code that I had tested on Linux and BSD for
inline colors.  It worked fine on both.  But on Solaris, the MUD
crashed whenever a message was sent.  I agonized over it for a while,
then -- on a whim -- I changed all the "*str = 0;" lines to
"*str = '\0';" and it ran fine.  <sigh>

> (we all know dak is always right all the time hehe :)

Actually, I'm usually wrong.  But I hide it well.


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

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