Hello,
During combing throught code of this library I noticed something that puzled me. Data reading function (for example "ReadCharData") use variable "bytesread" to store amount of bytes read from a file, to controll padding and the like, but only sometimes it seems to acount for bytes/element, other times just storing raw "fread" return variable (in this case it seems to see no difference between "bytesread" of the same amount of uint8 an uint16 elements). Is this supposed to be like this?
Thanks in advence for your time.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is wrong from the very beginning and bugs me for years. I already introduced variables readresult to improve the situation. One day, l think I will change the Read... and Inflate... functions to change the return value to a simple success/error value since this is the relevant information.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I considered this variable as mostly "funfact" and maybe some debug help, as it affects basically nothing... Except "Mat_VarRead5" where it's actually used for skipping padding in the file which in turn pushed me to ask this question. But AFAIK simply adding multiplications before "fread"s should be enought to actually tweak this one and get rid of issues with skipping padding. Or atleast that's what I deduced from my, still pretty basic, studies of .mat file documentation.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yea, I guess you are right. Either way I think that multiplying by size of data element should solve potential problems, since it would correct potential bugs in padding (since it uses "%8" to determine how much padding bytes are needed) while not affecting success checks (as long as they are just checks against "NULL").
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
During combing throught code of this library I noticed something that puzled me. Data reading function (for example "ReadCharData") use variable "bytesread" to store amount of bytes read from a file, to controll padding and the like, but only sometimes it seems to acount for bytes/element, other times just storing raw "fread" return variable (in this case it seems to see no difference between "bytesread" of the same amount of uint8 an uint16 elements). Is this supposed to be like this?
Thanks in advence for your time.
This is wrong from the very beginning and bugs me for years. I already introduced variables
readresult
to improve the situation. One day, l think I will change the Read... and Inflate... functions to change the return value to a simple success/error value since this is the relevant information.I considered this variable as mostly "funfact" and maybe some debug help, as it affects basically nothing... Except "Mat_VarRead5" where it's actually used for skipping padding in the file which in turn pushed me to ask this question. But AFAIK simply adding multiplications before "fread"s should be enought to actually tweak this one and get rid of issues with skipping padding. Or atleast that's what I deduced from my, still pretty basic, studies of .mat file documentation.
No, it definitely is not a funfact since it tells you if reading from file was successful. And in case of error you need to react and roll back.
Yea, I guess you are right. Either way I think that multiplying by size of data element should solve potential problems, since it would correct potential bugs in padding (since it uses "%8" to determine how much padding bytes are needed) while not affecting success checks (as long as they are just checks against "NULL").