🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac
Article #22436

Re: LSC fread limitation?

#22436
From: Spencer W. Thomas
Date: Thu, 03 Dec 1987 06:41
25 lines
1406 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: <2265@utah-gr.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!rutgers!cmcl2!nrl-cmf!umix!utah-gr!spline.utah.edu!thomas
References: <214@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!mnetor!uunet!husc6!rutgers!cmcl2!nrl-cmf!umix!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?
Message-ID: <2265@utah-gr.UUCP>
Date: Thu, 3-Dec-87 01:41:04 EST
Article-I.D.: utah-gr.2265
Posted: Thu Dec  3 01:41:04 1987
Date-Received: Sun, 6-Dec-87 10:23:29 EST
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
Keywords: LSC fread