chh9@quads.uchicago.edu (Conrad Halton Halling) (06/28/91)
I recently started programming using Think C. I would like advice on a simple, beginner's question for which I cannot find the answer in Inside Macintosh. I have stored tables of 64 doubles as different IDs of resource type 'CDNT'. My program will load one table from a specific ID (chosen by the user) and use the doubles in the table in a long series of calculations. For simplicity, I want to lock the handle to the resource so I can use a pointer in my calculations. I realize the size of this resource (640 bytes) is small, but I would like to know which is the best strategy for locking the handle: 1) I could set the "locked" attribute in the resource file, so that the handle is locked immediately when the resource is loaded into the application heap. 2) I could get the resource without the "locked" attribute set, then MoveHHi( myHandle ) and HLock( myHandle ). Thanks in advance for any help. E-mail replies will be sufficient, altho I read this newsgroup regularly. -- Con Halling chh9@midway.uchicago.edu
dorner@pequod.cso.uiuc.edu (Steve Dorner) (06/28/91)
In article <1991Jun27.174311.18097@midway.uchicago.edu> chh9@quads.uchicago.edu (Conrad Halton Halling) writes: >I realize the size of this resource (640 bytes) is small, but I would like >to know which is the best strategy for locking the handle: >2) I could get the resource without the "locked" attribute set, then > MoveHHi( myHandle ) and HLock( myHandle ). Unless you plan to be allocating memory during your calculations, I suggest you lock it when you start your calculations and unlock it when you're done. Skip the MoveHHi; it will be slow and won't buy you anything, UNLESS you allocate memory while the handle is locked. -- Steve Dorner, U of Illinois Computing Services Office Internet: s-dorner@uiuc.edu UUCP: uunet!uiucuxc!uiuc.edu!s-dorner
stevec@Apple.COM (Steve Christensen) (06/28/91)
chh9@quads.uchicago.edu (Conrad Halton Halling) writes: >I have stored tables of 64 doubles as different IDs of resource type 'CDNT'. >My program will load one table from a specific ID (chosen by the user) and >use the doubles in the table in a long series of calculations. For >simplicity, I want to lock the handle to the resource so I can use a >pointer in my calculations. > >I realize the size of this resource (640 bytes) is small, but I would like >to know which is the best strategy for locking the handle: > >1) I could set the "locked" attribute in the resource file, so that the > handle is locked immediately when the resource is loaded into the > application heap. > >2) I could get the resource without the "locked" attribute set, then > MoveHHi( myHandle ) and HLock( myHandle ). It's better to keep the resource unlocked and lock it as needed by calling HLock. You should be able to keep it unlocked much of the time, locking it only when you are directly referencing the contents of the block and memory might be moved... steve -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Steve Christensen Never hit a man with glasses. stevec@apple.com Hit him with a baseball bat.