Re: [cc65] calloc() not failing

From: Oliver Schmidt <ol.sc1web.de>
Date: 2012-11-13 11:43:41
Hi,

> 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.

That doesn't seem a real solution in general as it doesn't run the destructors.

Therefore the Apple2 C library contains the function rebootafterexit()
which does a coldstart in a clean way. The function itself does
nothing but it comes with a constructor that patches the destination
of the final JMP in the startup (and shutdown) code.

The nice thing is that the exec() implementation on the Apple2 uses
the very same technique (patching that final JMP destination) to have
the loader called that it has set up before. After setting everything
up exec() just calls exit() so all things are shut down cleanly before
JMPing to the temporary loader.

Maybe such an approach makes sense for other targets too...

Regards,
Oliver
----------------------------------------------------------------------
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 11:43:53 2012

This archive was generated by hypermail 2.1.8 : 2012-11-13 11:43:57 CET