Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!utgpu!water!watmath!clyde!cbosgd!osu-cis!osupyr!artsvax!mike
From: mike@artsvax.UUCP
Newsgroups: comp.sys.mac
Subject: LSC fread head scratcher
Message-ID: <213@artsvax.UUCP>
Date: Mon, 30-Nov-87 22:04:36 EST
Article-I.D.: artsvax.213
Posted: Mon Nov 30 22:04:36 1987
Date-Received: Thu, 3-Dec-87 22:39:44 EST
Organization: College of the Arts Computer Lab, OSU
Lines: 35
Keywords: LSC fread wierd

I'm trying to read entire large files into memory on the Mac.  (for speed
in writing them out)  Since I can't figure out how get the total size
of a file, I devised the following code.  Unfortunately, it doesn't
seem to work correctly.  Any comments would be appreciated.  For some
reason, it always reads 79 blocks from every file when run from a
MacII, and 44 blocks when run from a Plus.

#define MAXBUFF 153600 /* room for three hundred blocks */
do_read_file(fp)
FILE *fp;
{

  unsigned char buffer[300 * 512];
  unsigned char *buff;  /* I would have used malloc or calloc, but */
			/* everytime I called them the system crashes */

  buff = buffer;
  while((!feof(fp) && ((buff - buffer) <  MAXBUFF)){
    length = fread(buff,sizeof(char),512,fp);
    buff += length;
    }

  fclose(fp);

}



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Michael S. Czeiszperger      | Disclaimer: "Sorry, I'm all out of pith" 
  Systems Programmer I	      | Smail: Room 406 Baker      (614)
   College of the Arts        |        1971 Neil Avenue      292-
     Computer Lab             |        Columbus, OH 43210     0895
The Ohio State University     | UUCP: {decvax,ucbvax}!cbosgd!osupyr!artsvax!mike
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~