Path: utzoo!attcan!uunet!decwrl!mips!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!ncifcrf!lhc!mimsy!mojo!russotto From: russotto@eng.umd.edu (Matthew T. Russotto) Newsgroups: comp.sys.mac.programmer,aus.mac Subject: Re: Danger Will Robinson, traps for young player. Message-ID: <1990Aug20.143025.2160@eng.umd.edu> Date: 20 Aug 90 14:30:25 GMT References: <11591@wehi.dn.mu.oz> Sender: news@eng.umd.edu (The News System) Organization: College of Engineering, Maryversity of Uniland, College Park Lines: 33 In article <11591@wehi.dn.mu.oz> JON@wehi.dn.mu.oz (Jon Eaves) writes: >I want to extract the UserName from the Chooser. No problems, just use >tempHandle = GetString(CHOOSERNAME), then how do I get the "string" from >the tempHandle. The process I was using was > strcpy(tempString,PtoCstr((char *)(*tempHandle)); >Great, this sets tempString correctly. BUT, the Chooser Name field gets >mangled because the resource handle is now in 'C' string format. >When the application exits, the resource map is saved and the System >becomes unstable (Got the 'Cant Load the Finder', bomb !!) > >Now some questions. >1) Why the hell is the handle to the resource attached to that resource? You would have to ask an oldtimer@apple.com, but my guess would be MEMORY-- making copies each time you call GetString is expensive, especially in 128K. > Doesn't it make some sort of copy? At no stage do I explicitly use > ChangedResource(tempHandle);WriteResource(tempHandle); > Why is it saved then? It may not be-- it may only be changed until you reboot-- remember that there is only one resource handle for all applications that use the string. >2) What is the best way to extract stuff from 'tempHandle' so that things > like that don't happen? I presume there is a nice 'safe' way of doing > this. strncpy(tempString,((char *)(*tempHandle)) + 1, (size_t)(*(unsigned char *)(*tempHandle))); tempString[*(unsigned char *)(*tempHandle)] = '\0'; -- Matthew T. Russotto russotto@eng.umd.edu russotto@wam.umd.edu ][, ][+, ///, ///+, //e, //c, IIGS, //c+ --- Any questions?