🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac
Article #23988

Re: LSC fread limitation?

#23988
From: Spencer W. Thomas
Date: Thu, 21 Jan 1988 00:00
25 lines
1284 bytes
In article <214@artsvax.UUCP> mike@artsvax.UUCP (Michael Czeiszperger) writes:
>fread(buffer,sizeof(char),300*512,fp);
>
>... always reads in only 44 blocks ... It always returns the number 44*512...
>Does anyone have any idea why?

Well, let's look at it.

300*512 = 153600

153600 mod 65536 = 22528

22528 / 512 = 44

Therefore we can conclude that LSC's 16 bit integer arithmetic is
truncating your result.  In fact, the documentation for fread claims
that the count argument is an int, so you really can't do better than
32767 bytes at once (unless you set size_of_ptr to something bigger
than one).

What happens if you use
	fread( buffer, 300, 512, fp );
?

=Spencer   ({ihnp4,decvax}!utah-cs!thomas, thomas@cs.utah.edu)
Technical Details
Message-ID: <2265X@utah-gr.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!ptsfa!ames!nrl-cmf!cmcl2!husc6!ut-sally!utah-cs!utah-gr!spline.utah.edu!thomas
References: <214@artsvax.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!ptsfa!ames!nrl-cmf!cmcl2!husc6!ut-sally!utah-cs!utah-gr!spline.utah.edu!thomas
From: thomas%spline.utah.edu.uucp@utah-gr.UUCP (Spencer W. Thomas)
Newsgroups: comp.sys.mac
Subject: Re: LSC fread limitation?
Keywords: LSC fread
Message-ID: <2265X@utah-gr.UUCP>
Date: 21 Jan 88 00:00:00 GMT
References: <214@artsvax.UUCP>
Sender: news@utah-gr.UUCP
Reply-To: thomas%spline.utah.edu.UUCP@utah-gr.UUCP (Spencer W. Thomas)
Organization: University of Utah CS Dept
Lines: 25