logoalt Hacker News

somenameformetoday at 7:41 AM3 repliesview on HN

Doesn't that break anything relying on the return value? fread gives you the number of objects read as a return. So I think a pretty typical thing would be to fread and then parse that number of characters, and that'd just break?


Replies

jcultoday at 8:16 AM

I've seen a lot of code that just assumes fread / fwrite succeeded without bothering to check the return value...

But in this case if the code was calling fread 65536 times in a loop and getting 64KiB each time it wouldn't be good either!

Sounds like the parent comment had to fix this with the internal cache thing to speed up the small freads. I think they meant the easy fix would have been swapping the args in the original / caller code.

show 1 reply
koolalatoday at 8:30 AM

I think they turned it from a tiny file read to a tiny ram read.

DonHopkinstoday at 8:22 AM

The type of programmer who swaps the args to fread tends to be the type of programmer who doesn't bother to check the return value, fortunately.

Edit: mort96: So did you check the return value or not?

show 2 replies