-
Notifications
You must be signed in to change notification settings - Fork 28
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
Why not deal with stack-allocated calibration object instead of heap-allocated? #26
Comments
I have no objection to making this change. Currently the calibration object is only used in the tests, since I've put work on it on hold for a long time, so the switch would be easy. However, the same allocation method is used in |
I agree that this can be changed. Can we track down all the places where we'll need to update the Cython bindings due to this change? |
Any IDE's code search option can do it. Personally I prefer |
Hi all,
Making So here is the proposal (somehow inspired by petsc, not involving many modification, and probably to be further elaborated):
which is there for every structure (also for the simplest ones and in such cases just wraps the Indeed, a reduction of such proposal which just focuses on 4 and then 1 is possible: I would keep 4. so to have a uniform de-allocation policy based on specific free-like functions (which can possibly just forward the call to I would keep 1. so to make clear that Points 2 and 3 can be cast in the current design What do you think? |
1 and 2 are acceptable. Then whenever possible we make it the user's responsibility to allocate. However, we might as well prevent errors and misuse of 4 Is a good idea, and actually we also miss As for 3, I'd rather leave that as individual decision for each function. If the structures are not touched, pass by reference saves a copy. If it is touced, and we can't get rid of this touching, may be better to pass by value, then discard the copy. |
In the
calibration.{c,h}
files, the final calibration object is currently instantiated during the callread_calibration()
(below) and owned by the caller via a pointer.Since the whole calibration struct is fully stack-like allocated, why not give full ownership to the caller and have something like
where
int
is a return flag.Moreover, this way
. there is no ambiguity on the way the calibration object has to be deallocated
. faulty calls which (for some misterious reasons) don't capture the returned value do not end up in memory leaks
The text was updated successfully, but these errors were encountered: