home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / mac / programm / 21051 < prev    next >
Encoding:
Internet Message Format  |  1993-01-08  |  1.3 KB

  1. Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!uwm.edu!ogicse!reed!bowman
  2. From: bowman@reed.edu (BoBolicious)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Re: assigning a StringPtr to an array of Str255s?
  5. Message-ID: <1993Jan9.005725.3063@reed.edu>
  6. Date: 9 Jan 93 00:57:25 GMT
  7. Article-I.D.: reed.1993Jan9.005725.3063
  8. References: <16B50FE12.UC525655@mizzou1.missouri.edu>
  9. Organization: Reed College, Portland, OR
  10. Lines: 23
  11.  
  12. In article <16B50FE12.UC525655@mizzou1.missouri.edu> UC525655@mizzou1.missouri.edu (Mark Eaton) writes:
  13. >struct someStuff
  14. >    {
  15. >    ...
  16. >    str255  contents[99];
  17. >    }
  18.  
  19. Instead of Str255, methinks you want "unsigned char *".
  20.  
  21. Your scheme allocates 256*99 ~= 25K; that is, it actually allocates 99
  22. 256 byte array.  You code, however, assumes you want these to be pointers,
  23. not the actual storage space.  If you *do* want the storage space, then
  24. when you use ioNamePtr, you'll need to explicitly copy the strings from
  25. wherever ioNamePtr is pointing into the appropriate string, something like
  26.  
  27. pStrcpy(&(someStuffStruct->contents[i]),ioNamePtr);
  28.  
  29. chars,
  30. bobo              In seeking the unattainable,
  31. bowman@reed.edu            simplicity only gets in the way.
  32. "On Monday, numbers floated everywhere, and the world was full of 
  33. approximations."  -- Spencer Heinz, _The Oregonian_, 1/5/93
  34.