Refactor code and fixed bug on x64
@codereader review code please
Thank you!
Can you give me a description of the problem you fixed in the picomodel library? I want to add an entry to the bugtracker for the release changelog.
Can you give me a description of the problem you fixed in the picomodel library? I want to add an entry to the bugtracker for the release changelog.
@codereader,
this change applies only to 64 bit systems.
bug is a transformation of a dangerous explicit type pointer
typedef picoByte_t picoColor_t[ 4 ]; -> unsigned char picoColor_t[ 4 ];
it turns out that we unsigned char** converts to int** on 32 and 64 bit systems there will be different values.
You can check this piece of code with debug mode on Win32 and x64
The size of the ptrdiff_t is equal in both systems
I don't really like that particular piece of code, but isn't this just loading the 4 bytes of memory occupied by the picoColor array by casting the location to int* and de-referencing that? sizeof(int) is 4 bytes on both platforms, as are 4x unsigned chars. By casting it to ptrdiff_t* it will compare 8 bytes - wouldn't this cause an overflow when accessing that memory at color[j]?