home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!darkstar.UCSC.EDU!cats.ucsc.edu!speth
- From: speth@cats.ucsc.edu (James Gustave)
- Newsgroups: comp.sys.mac.programmer
- Subject: Recommended way to deal with large memory buffers?
- Date: 23 Jan 1993 03:35:43 GMT
- Organization: University of California; Santa Cruz
- Lines: 24
- Message-ID: <1jqeefINNcio@darkstar.UCSC.EDU>
- References: <9301221923.aa23160@Paris.ics.uci.edu>
- NNTP-Posting-Host: am.ucsc.edu
-
-
- I'm working on an encryption application, and I need to go through a file,
- encrypt it, and write it to a new file. The encryption routine takes a Ptr
- to a buffer, and a count of the number of bytes to process. For small files,
- it makes sense to read the whole file into the buffer and do the encryption.
- However, this means that the maximum size of the file to be encrypted is
- determined by the amount of memory the program can allocate. On the other
- hand, if I did the encryption incrementally, writing the parts to a temp file,
- then there might be a lot of unnecessary disk access which would slow down
- the process.
-
- What is the recommended way of working with large files? Should I read it
- all in, or use temp files? Or should I read as much in as possible and only
- create temp files when necessary (maybe I just answered my own question :)
-
- Another question, sometimes I need to add a prefix packet to the beginning
- of the buffer. Is there an easy way to prepend stuff to a buffer, without
- allocating a new buffer, writing the info, then doing a block move?
-
- Thanks.
-
- --
- ________________________________________________________________________________
- james speth email for pgp 2.0 public-key speth@cats.ucsc.edu
-