Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!kddlab!atrpost!atr-la!alain From: alain@atr-la.atr.co.jp (Alain de Cheveigne) Newsgroups: comp.sys.mac.programmer Subject: Re: ROM doesn't unlock Handles (was: ROM unlocks Handles). LONG Message-ID: <3889@atr-la.atr.co.jp> Date: 27 Dec 89 01:29:08 GMT References: <3875@atr-la.atr.co.jp> <4525@helios.ee.lbl.gov> <3888@atr-la.atr.co.jp> Organization: ATR International,Japan Lines: 33 In-reply-to: alain@atr-la.atr.co.jp's message of 27 Dec 89 01:01:32 GMT Ooops! Butter fingers! My last message escaped unfinished. Sorry. Here is the end of what I had to say: [...] This far from covers all needs. All depends on the order in which you allocate and release memory. Schematically: - if you need memory throughout the program, you can use global space (though you might not want to, for other reasons), - if memory allocated in a routine is always released on exit (meaning that memory is released in strictly the inverse order in which it was allocated), it can go on the stack, - if you want memory to stay around after a routine returns (say, a window creation routine) and you're unlikely to need to deallocate it, then use a Pointer, - if you need to allocate and deallocate in any order, then you must use Handles to avoid heap fragmentation. By this reasoning, WindowPtrs should have been Handles, since the user can open and close them in any order. The choice between Handle and Pointer in a program depends on the program's overall structure, and the kind of user interaction you wish to allow. If you can get away with Pointers, then by all means do. Alain de Cheveigne, alain@atr-la.atr.co.jp