TIP: Click on subject to list as thread! ANSI
echo: cis.tandy.coco
to: Bob van der Poel 76510,2203 (X)
from: Bruce MacKenzie 71725,376
date: 1990-05-15 17:56:15
subject: #3505-#c-array initialization

#: 3512 S10/Tandy CoCo
    15-May-90  17:56:15
Sb: #3505-#c-array initialization
Fm: Bruce MacKenzie 71725,376
To: Bob van der Poel 76510,2203 (X)

String literals are the only type of data that are left in the program area. I
believe the ANSI enhancement of C adds the specifier 'const' which would allow
other types of data to be handled in that way.  With standard C everything is
copied into the data area.

Reading the data in from a disk file has much to say for it.  If all you're
doing is plugging it once into GP buffers there's no reason to have a second
copy of the data in memory at all.  The down side is that you always have to
worry that the data file is where the program expects it to be. It is cleaner
to have it loaded in along with the program.  If you have enough memory left
over in your last 8K block of program memory for a data module then you don't
even waste any memory.

You can use a data module as variable memory as you described.  You just have
to be sure to update the module's CRC if you want OS9 to link to it again.  In
my opinion, however, this is bad practice since modifying a data module makes
the program non-reentrant.  Say a program modifies a data module and you then
go to another window and start the same program as a second process.  If the
first process didn't update the CRC, the second process can't link to the data
module.  If the CRC has been updated, the second process begins with a modified
data module rather than with it de-novo.  If both processes continue to modify
the data module to their own ends chaos can ensue.

There is 1 Reply.

SOURCE: compuserve via textfiles.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.