[comp.sys.mac.programmer] Setting up multiple heaps

Andrew_James_Peterson@cup.portal.com (08/29/89)

I'm going to try to set up an application that uses multiple heaps.
From preliminary investigation, I haven't been able to find any
sample code that does this, and the IM documentation is unclear
on a number of issues.  Rather than experimenting forever, I'd
rather take advantage of others' research.

My question:  Is there public domain code that does this?  Could
you send it to me or let me know where to find it?  Does Apple
have any?

Thanks,
Andy
andrewjp@cup.portal.com

siegel@endor.harvard.edu (Rich Siegel) (08/30/89)

In article <21673@cup.portal.com> Andrew_James_Peterson@cup.portal.com writes:
>
>I'm going to try to set up an application that uses multiple heaps.
	
	OK, but why?

	Setting up a new heap zone is pretty simple:

	var
		hcZone: THz;

	procedure Heap;
		var
			oldzone: THz;

	begin
		OldZone := GetZone;
		hcZone := THz(NewPtr(MaxZoneSize));
		InitZone(nil, 16, Ptr(Ord4(hcZone) + MaxZoneSize), Ptr(hcZone));
		SetZone(OldZone);
	end;

To make your new zone the current zone, do a 

	SetZone(hcZone);

Multiple heaps generally aren't required, unless you're THINK Pascal or
you want to perform some action on your own heap which requires blocks
to be allocated, and you don't want to affect your own heap.

R.
~~~~~~~~~~~~~~~
 Rich Siegel
 Staff Software Developer
 Symantec Corporation, Language Products Group
 Internet: siegel@endor.harvard.edu
 UUCP: ..harvard!endor!siegel

"There is no personal problem which cannot be solved by sufficient
application of high explosives."

~~~~~~~~~~~~~~~