Patrick Georgi wrote:
if(!fwrite(cmos_table, (int)(ct->size-1), 1, fp)) {
It would be better to check that all bytes have been written not only some, so do something like:
if(fwrite(cmos_table, (int)(ct->size-1), 1, fp) != ct->size-1) {
fwrite returns the number of successful elements, not bytes. Given that there's only 1 element to write (of size ct->size-1),
I have had very bad experience with this, where things did not work unless element size=1 and number of elements=bytestowrote, so I continue to write all code that way.
Unfortunately I can't say what the circumstances were, but when I saw it I decided better be safe. And a smart libc could coalesce anyway.
//Peter