Article View: comp.sys.mac
Article #22440Re: LSC fread head scratcher
From: jwhitnel
Date: Wed, 02 Dec 1987 18:00
Date: Wed, 02 Dec 1987 18:00
39 lines
1649 bytes
1649 bytes
In article <213@artsvax.UUCP> mike@artsvax.UUCP (Michael Czeiszperger) writes:
>#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 */
Use mlalloc (sp)? for larger then 32K
>
> buff = buffer;
> while((!feof(fp) && ((buff - buffer) < MAXBUFF)){
> length = fread(buff,sizeof(char),512,fp);
> buff += length;
> }
Why not use the much simpler:
long length;
char * buffer;
unsigned char *buffer;
buffer = mlalloc(MAXBUFF);
if ( buffer == NULL )
/* Not enough memory */
length = fread( buffer, 512, 300, fp);
return( length );
> Michael S. Czeiszperger | Disclaimer: "Sorry, I'm all out of pith"
Jerry Whitnell Lizzi Borden took an axe
Communication Solutions, Inc. And plunged it deep into the VAX;
Don't you envy people who
Do all the things You want to do?
Technical Details
Message-ID:
<1310@csib.csi.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!rutgers!husc6!think!ames!amdahl!nsc!csi!jwhitnelReferences:
<213@artsvax.UUCP>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!rutgers!husc6!think!ames!amdahl!nsc!csi!jwhitnel From: jwhitnel@csi.UUCP Newsgroups: comp.sys.mac Subject: Re: LSC fread head scratcher Message-ID: <1310@csib.csi.UUCP> Date: Wed, 2-Dec-87 13:00:48 EST Article-I.D.: csib.1310 Posted: Wed Dec 2 13:00:48 1987 Date-Received: Sun, 6-Dec-87 15:41:37 EST References: <213@artsvax.UUCP> Reply-To: jwhitnel@csib.UUCP (Jerry Whitnell) Organization: Communications Solutions Inc., San Jose, Ca Lines: 39 Keywords: LSC fread wierd