tbeu / matio

MATLAB MAT File I/O Library
https://matio.sourceforge.io
BSD 2-Clause "Simplified" License
330 stars 97 forks source link

improve const correctness like in the example `Mat_VarCreate` #137

Closed Febbe closed 8 months ago

Febbe commented 4 years ago

change

EXTERN matvar_t  *Mat_VarCreate(const char *name,enum matio_classes class_type,
                      enum matio_types data_type,int rank,size_t *dims,
                      void *data,int opt);

To

EXTERN matvar_t  *Mat_VarCreate(const char *name, enum matio_classes class_type,
                      enum matio_types data_type, int rank, size_t const*dims,
                      void const*data,int opt);

There are also other places where this is necessary.

tbeu commented 4 years ago

This touches the API which I won't do at the moment. You still can update it in matio.h and use in your application w/o further issue, I believe.

Febbe commented 4 years ago

Right, I see your point. The only thing which would work, is adding those functions and mark the other as deprecated. For now I'll just const_cast(data) them. But in some unlucky cases, this could lead to undefined behavior.

tbeu commented 8 months ago

Finally resolved by 0884b80a7ee5783b6193d7e2c58f997d121d3245.