[comp.sys.mac.programmer] Linked lists

cs220x2a@ducvax.auburn.edu (CS220X) (02/11/91)

I'm working on an application in Think Pascal 3.0 and need to use a linked 
list.

The problem is, how do I avoid the memory manager moving all of my nodes 
around?  I could make them all non-relocatable, but that would result in a 
tremendously fragmented stack (or is it heap? I always forget).

The other option would be to reference each node as a handle, thereby 
eliminating the movement problem, but causing some other problems in terms of 
extra memory usage.

Finally, since I know I'll never have more than 50 elements, I could use an 
array-implemented linked list, but I'd rather use pointers and not place any 
restrictions on something that may expand in the future.

What do you think? What's the best way to implement a linked list on the 
Macintosh?

Thanks,
Wade Williams
cs220x2a@ducvax.auburn.edu

ml27192@uxa.cso.uiuc.edu (lanett mark) (02/12/91)

cs220x2a@ducvax.auburn.edu (CS220X) writes:

>I'm working on an application in Think Pascal 3.0 and need to use a linked 
>list.

>The problem is, how do I avoid the memory manager moving all of my nodes 
>around?  I could make them all non-relocatable, but that would result in a 
>tremendously fragmented stack (or is it heap? I always forget).

>Finally, since I know I'll never have more than 50 elements, I could use an 
>array-implemented linked list, but I'd rather use pointers and not place any 
>restrictions on something that may expand in the future.

If you're only dealing with ~50 items (for now) use NewPointer. That few items
won't eat up so much space or fragment the heap much. NewPointer tries to
compact the heap (not stack) before allocating anyway.

Mark Lanett
--
///////////////////////////////////////////////////////////////////////////////
Mark Lanett						ml27192@uxa.cs.uiuc.edu