Re: [cc65] calloc() not failing

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2012-11-13 00:14:10
Hi!

On Mon, Nov 12, 2012 at 11:49:42PM +0100, Marc 'BlackJack' Rintsch wrote:
> If I set the second parameter to 204 then it crashes the *first* time I
> run it.  Same symptom — screen memory fills half way with zero bytes,
> then the system hangs.

Ok, thanks for the report! There has been a stupid error in calloc. I'm glad
you didn't see it either, so I'm not looking too dumb:-) The error was only
triggered if malloc returned NULL, which is the reason, why calloc seemed to
work for others.

> That worked for me all the years with all the programs I wrote.  If this
> was just a lucky coincidence then programs should not return to the
> BASIC prompt and leave a ”runnable” program behind IMHO.  It's quite a
> surprise for me.

How can that work? Initialized data is no longer initialized correctly if the
program runs the second time. That may or may not cause trouble. Making the
program unrunable needs code and I don't see a reason to place this penalty on
all programs. If you prefer not to be able to run your program again, you may
choose to terminate your program by jumping to the coldstart vector or
whatever. This is what most games do.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz@musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue Nov 13 00:14:43 2012

This archive was generated by hypermail 2.1.8 : 2012-11-13 00:14:46 CET