[comp.sys.mac.programmer] Creating big new handle

bartels@haydn.kulesat.uucp (04/12/89)

It don't succeed to create a large handle. The program stops, at the line
image = Newhandle((long) 4096)
and I had to restart the computer. Does anyone know how to acces a large 
amount of memory without crashing the computer.

#include <Types.h>
#include <Memory.h>
#include <Quickdraw.h>
#include <Palette.h>
#include <Fonts.h>
#include <Events.h>
#include <Menus.h>
#include <Windows.h>
#include <TextEdit.h>
#include <Dialogs.h>
#include <Desk.h>
#include <OSUtils.h>
#include <ToolUtils.h>
#include <SegLoad.h>
#include <stdio.h>
#include <ioctl.h>

typedef BitMap *BitMapPtr;


main()
{
CWindowPtr ImagePort;
CTabHandle CThan;
Handle Image;
Rect Imagerect;
PixMapHandle ImageMap;
long int i;
long int refCon;
CWindowRecord wRecord;


InitGraf(&qd.thePort);
InitFonts();
InitWindows();
InitMenus();
TEInit();
InitDialogs(nil);
InitCursor();


SetRect(&Imagerect,40,40,350,350);
ImagePort = (CWindowPtr) NewCWindow((Ptr) &wRecord,&Imagerect,"\pMijn eerste beeld",1,
                       documentProc, (WindowPtr) -1 ,0,refCon = 4);
while(! Button());
CThan = (CTabHandle) (NewHandle(((long) 255) * 4 + 10));
(*CThan)->ctSeed = GetCTSeed();
(*CThan)->ctFlags = 0;
(*CThan)->ctSize = 256;
for (i=0; i<=255; i++)
  {(*CThan)->ctTable[i].value = (short) i;
   (*CThan)->ctTable[i].rgb.red = (unsigned short) (255 * i);
   (*CThan)->ctTable[i].rgb.green = (unsigned short) (255 * i);
   (*CThan)->ctTable[i].rgb.blue = (unsigned short) (255 * 0);};
SysBeep(100);
Image = NewHandle((long) 1024);
for (i=0; i<=1023; i++)
{*(*Image + i) = (short)((i + 1)/32);}
SetRect(&Imagerect,0,0,32,32);
ImageMap = NewPixMap();
SysBeep(100);
(*ImageMap)->baseAddr = *Image;
(*ImageMap)->rowBytes = (0x8000|32);
(*ImageMap)->bounds = Imagerect;
(*ImageMap)->pmTable = CThan;
SysBeep(100);
CopyBits(((BitMapPtr)*ImageMap),((BitMapPtr)*(ImagePort->portPixMap)),
  &Imagerect,&Imagerect,0,0);
while(! Button());
}

Thanks for your attention,


					Yours sincerly,
								
									
					Rudi Bartels
					KU Leuven 
					Faculteit der Toegepaste Wetenschappen
					ESAT-MI2
					Kard. Mercierlaan 94
					3030 Heverlee
					Belgium
					email: bartels@kulesat.uucp
					Fax: 32-16-221855