home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / mac / programm / 22014 < prev    next >
Encoding:
Text File  |  1993-01-23  |  1.6 KB  |  33 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!charon.amdahl.com!netcomsv!netcom.com!cokenias
  3. From: cokenias@netcom.com (Damon Cokenias)
  4. Subject: Re: Recommended way to deal with large memory buffers?
  5. Message-ID: <1993Jan23.085039.8860@netcom.com>
  6. Organization: Netcom - Online Communication Services (408 241-9760 guest)
  7. References: <9301221923.aa23160@Paris.ics.uci.edu> <1jqeefINNcio@darkstar.UCSC.EDU>
  8. Date: Sat, 23 Jan 1993 08:50:39 GMT
  9. Lines: 22
  10.  
  11. In article <1jqeefINNcio@darkstar.UCSC.EDU> speth@cats.ucsc.edu (James Gustave) writes:
  12. >
  13. >  I'm working on an encryption application, and I need to go through a file,
  14. >encrypt it, and write it to a new file.  The encryption routine takes a Ptr
  15. >to a buffer, and a count of the number of bytes to process.  For small files,
  16. >it makes sense to read the whole file into the buffer and do the encryption.
  17. >However, this means that the maximum size of the file to be encrypted is
  18. >determined by the amount of memory the program can allocate.  On the other
  19. >hand, if I did the encryption incrementally, writing the parts to a temp file,
  20. >then there might be a lot of unnecessary disk access which would slow down
  21. >the process.
  22.  
  23. Well, you could read in your maximum amount to encrypt, pass it to your
  24. encryption routine.  Then, reposition the file mark and write the information
  25. to the beginning of the file.  Obviously, this could be a pain if you're also
  26. doing compression.  Then, the file mark will be advanced to the place you
  27. left it after the initial read and then you can continue to process the file.
  28.  
  29. This ha the advantage of not using any excess disk space.
  30.  
  31. -Damon Cokenias
  32.  
  33.