Closed scemama closed 1 year ago
instead of const char my_string[256] = "hello"
, we should use const char* my_string = "hello"
I created a const and a non_const variable. If a new array is allocated, we use index_p and free the non_const variable. If we can use the initial variable, index_p is NULL and we don't use the non_const variable.
If a struct has a fixed-size string + some data, making an overflow in the string will corrupt data of the struct. So it is recommended to put strings at the end of structs, so that important data are less likely to be overwritten by s string overflow.
@q-posev ping!
@q-posev ping!
@scemama I responded a few days ago in this thread. I still believe that changes in this PR break the I/O of indices in 32-bit, which is why I am not ready to merge it.
@scemama ping 🙂
@scemama thanks! I think the name of the PR can be changed to reflect that there was a major refactoring of the unit tests. I have one comment, let me know if you prefer to get it fixed in a separate PR or in this one:
We discussed testing the io_dset_sparse
with different values of mo_num
in order to test at least the 8/16-bit and 32-bit code paths.
Yes! It is better if I fix the tests in this PR also. I planned to do it, but I forgot...
We discussed testing the io_dset_sparse with different values of mo_num in order to test at least the 8/16-bit and 32-bit code paths.
Done!
Pointers
instead of
const char my_string[256] = "hello"
, we should useconst char* my_string = "hello"
index_p
I created a const and a non_const variable. If a new array is allocated, we use index_p and free the non_const variable. If we can use the initial variable, index_p is NULL and we don't use the non_const variable.
String overflow
If a struct has a fixed-size string + some data, making an overflow in the string will corrupt data of the struct. So it is recommended to put strings at the end of structs, so that important data are less likely to be overwritten by s string overflow.