[comp.sys.mac.programmer] memory/segment question

hilgedic@hatteras.cs.unc.edu (John Hilgedick) (03/08/91)

Howdy there,

I am currently working on an application that requires the use of a very large
array (1,000,000 bytes).  I have virtually no experience programming on a
mac (so word you help carefully please).  It seems that under the mac there
is a 32K barrier.  Does anybody out there no a quick and easy way to break
this?  All answers will be gratefully considered.  Please, no suggestions
about using the hard disk for holding chunks of the array - this thing needs
to run like lightning.  Please send mail.  Include your name so that we will
know what to name the child.  Thanks,

- john
 

fabio@applelink.apple.com (Fabio Pettinati) (03/09/91)

In article <2140@borg.cs.unc.edu> hilgedic@hatteras.cs.unc.edu (John 
Hilgedick) writes:
> I am currently working on an application that requires the use of a very 
> large array (1,000,000 bytes).  I have virtually no experience programming
> on a mac (so word you help carefully please).  It seems that under the mac
> there is a 32K barrier.  Does anybody out there no a quick and easy way to
> break this?  All answers will be gratefully considered.  Please, no
> suggestions about using the hard disk for holding chunks of the array - this
> thing  needs to run like lightning.  Please send mail.  Include your name so
> that we will know what to name the child.  Thanks,
> 
> - john

John,

the 32K barrier does not apply if you dynamically allocate the memory you 
need. In Unix you would use malloc/free for that. In the Macintosh world, 
you should use NewPtr/DisposPtr for non-relocatable blocks or 
NewHandle/DisposHandle for relocatable ones. Inside Macintosh, as usual, 
provides you with the gospel. If you use Think C, please remember to 
declare the block size as being of type 'long", so that it will be 32 bits 
long; in MPW C you use either "int" or "long".

Fabio Pettinati
Apple's Scientific and Engineering Evangelist

Apple Evangelism
#include <stddisclaimer.h>