[DGD]hmm.. this seems to not be goin through...

Gregory D Lewis glewis at maths.adelaide.edu.au
Wed Apr 26 06:33:58 CEST 2000


> Bang!  Here's your problem.  char *tmptxt defines tmptxt as a pointer to
> a string.  It doesn't allocate any storage for the string.  You need to
> allocate some space with malloc(), and make sure it gets freed at some
> point.  LPC has garbage collection and will do this for you.  C doesn't.

Long time since I've looked at the driver code, but DGD has its own memory
management functions which you may well need to use instead of malloc()/free().

> Also, LPC strings are probably stored in a different way to C strings.
> Null is a legal character in an LPC string, isn't it?  

Yes, at least in DGD.  It kind of is with MudOS but not really (from memory
it gets confused about its length in some circumstances).

> That would imply
> they're stored with a separate length, instead of C's null-terminating
> bogosity.  

Yes.

> And there's probably reference counts and other stuff for
> garbage collection.  I've never looked at the driver source, but I'd be
> very surprised if you can take strings from LPC and expect them to look
> like C strings.

Depends on what you want to do with them.  If you care about the possibility
of the \0 character you should avoid using strlen, strcpy, etc.  If you
don't care about this, then you can get away with it.

> In any case, you shouldn't be modifying the driver unless you're doing
> something that genuinely can't be done in LPC.  It's only asking for
> trouble when you try to upgrade to a new version of the driver.

Agreed.

-- 
Greg Lewis                              Applied Maths Department
Email : glewis at maths.adelaide.edu.au    University of Adelaide
--
If you pick up a starving dog and make him prosperous, he will not bite
you.  This is the principal difference between a dog and a man.
		-- Mark Twain

List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list