Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!mips!news.cs.indiana.edu!noose.ecn.purdue.edu!gn.ecn.purdue.edu!jess From: jess@gn.ecn.purdue.edu (Jess M Holle) Newsgroups: comp.sys.mac.programmer Subject: Re: How to best do a linked list on Mac Message-ID: <1991Jun10.171134.4212@gn.ecn.purdue.edu> Date: 10 Jun 91 17:11:34 GMT Sender: jess@gn.ecn.purdue.edu (Jess M Holle) Organization: Purdue University Engineering Computer Network Lines: 34 Well, I received this response by e-mail and was asked to post it. Here it is: ------------------------------------------------------------------ typedef struct MyLinkedListType { struct MyLinkedListType * * next ; char data [ DATASIZE ] ; } MyLinkedListType ; void InsertAfter ( char * data , MyLinkedListType * * * head ) { MyLinkedListType * * it = ( MyLinkedListType * * ) NewHandle ( sizeof ( * * it ) ) ; if ( ! it ) { SeriousOSErr ( outOfMemory ) ; } /* BlockMove doesn't move memory, so we don't have to lock the handle */ BlockMove ( data , ( * it ) -> data , DATASIZE ) ; if ( * head ) { ( * it ) -> next = ( * * head ) -> next ; ( * * head ) -> next = it ; } else { * head = it ; ( * it ) -> next = NULL ; } } ---------------------------------------------------------------- Jess Holle