I am currently programming an application for smartphones using C++ and the NDK. For reading external files, I use fread
. This works well on Windows, however, on Android phones, I got a mess with my implementation of the deflate decompressor. Of course I thought, there something wrong with my implementation of deflate, but it didn't really make sense as everything worked perfectly on Windows machines. After hours, I was finally able to track down the problem to fread
.
I am reading a file of size 4790954 and the return value of fread
is also 4790954. I, however discovered, that the buffer starts to contain trash at offset: 4194304. Exactly 4MB. Is there any known limitation on blocksize to be read at once that are defined in ANSI C I am not aware of?? Also, isn't that considered a bug, if the Google NDK fread
function returns an amount of read bytes of 4790954, if it however, only read 4194304 bytes (4MB)?