-
Notifications
You must be signed in to change notification settings - Fork 51
OpenSSF silver badge: minor refactor C API implementation #1269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are here, please fix the additional problems in the dataset pointer check. Namely for the attribute pointers.
power-grid-model/power_grid_model_c/power_grid_model_c/src/dataset.cpp
Lines 131 to 137 in b951eff
| void PGM_dataset_const_add_attribute_buffer(PGM_Handle* handle, PGM_ConstDataset* dataset, char const* component, | |
| char const* attribute, void const* data) { | |
| call_with_catch(handle, [dataset, component, attribute, data] { | |
| safe_ptr_get(cast_to_cpp(dataset)) | |
| .add_attribute_buffer(safe_str_view(component), safe_str_view(attribute), safe_ptr(data)); | |
| }); | |
| } |
power-grid-model/power_grid_model_c/power_grid_model_c/src/dataset.cpp
Lines 165 to 171 in b951eff
| void PGM_dataset_writable_set_attribute_buffer(PGM_Handle* handle, PGM_WritableDataset* dataset, char const* component, | |
| char const* attribute, void* data) { | |
| call_with_catch(handle, [dataset, component, attribute, data] { | |
| safe_ptr_get(cast_to_cpp(dataset)) | |
| .set_attribute_buffer(safe_str_view(component), safe_str_view(attribute), safe_ptr(data)); | |
| }); | |
| } |
power-grid-model/power_grid_model_c/power_grid_model_c/src/dataset.cpp
Lines 197 to 203 in b951eff
| void PGM_dataset_mutable_add_attribute_buffer(PGM_Handle* handle, PGM_MutableDataset* dataset, char const* component, | |
| char const* attribute, void* data) { | |
| call_with_catch(handle, [dataset, component, attribute, data] { | |
| safe_ptr_get(cast_to_cpp(dataset)) | |
| .add_attribute_buffer(safe_str_view(component), safe_str_view(attribute), safe_ptr(data)); | |
| }); | |
| } |
These data pointers should be allowed to be nullptr, if the total number of the elements in the component is zero. Users may still create such an attribute buffer (e.g. empyt vector or empty span, or empty numpy array) in an automatic way. But the data pointer maybe nullptr which is well defined.
i am implementing that as we speak but it is something we really want to allow? |
…disallowed Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
|



Cherry-picked changes from #1264
Re-opened a new PR as #1264 was superceded by #1266.
This PR is also rebased off
mainrather than #1241 to allow easier development.