RAII / resource ownership cleanup in selected C++ (Tello decoder, hospital person plugin, exercise templates) #3680
Replies: 1 comment 1 reply
-
|
Hi @shailigandhi-oss , I'm sorry but I don't understand your proposal. It is not directly related to project #2 at all. It seems to me that you have not properly understood the RoboticsAcademy base code. Feel free to USE RoboticsAcademy and create your solutions for several available exercises. After that, study the base source code as RoboticsAcademy as developer. Those steps will give you a good background to send a meaninful proposal. And focus on the open issues at RoboticsAcademy repo. Take a look at #3381. In addition, I'm afraid is too late for a sensible feedback from the potential mentors and for meaningful contributions on your side before the submission deadline. Just follow the applicant instructions, fill the required form and take a look at https://github.com/orgs/JdeRobot/discussions/383. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
I’d like to contribute small, behavior-preserving refactors that apply RAII-style resource management in a few C++ areas: clearer ownership, safer teardown on errors, and less reliance on manual
new/deleteor raw OS handles. I’m opening this under Ideas to check whether maintainers want this direction before I invest in PRs and build/test on your stack.Motivation (what’s fragile today)
Several spots pair manual acquisition with manual release or return raw owning pointers without a documented owner:
AVPacketneed consistent free/close paths. If initialization fails partway through the constructor, partial state may not match what a destructor would clean up. Mixingnew/deleteforAVPacketwith C APIs also splits ownership style.intandclose()in a plugin destructor works until refactors add early returns, error paths, or unclear initialization order; a scoped FD type makes “close exactly once” a local invariant.newin APIs likeget_laser_data()(raw pointer return) ornew Lap()passed into async WebSocket code makes leaks and double-free risks likely for students and reviewers unless ownership is explicit.This is less about “performance optimization” and more about robustness, exception safety where applicable, and maintainability.
Proposed scope (concrete locations)
CustomRobots/tello_phy/tello_ros/tello_driver/h264decoder/h264decoder.{hpp,cpp}CustomRobots/amazon_hospital/src/person.cppexercises/vacuum_cleaner/cpp_template/HAL.hpp(get_laser_data)exercises/follow_line/cpp_template/WebGUI.hpp(Laplifetime vssession)I would not propose edits to vendored/third-party blobs such as
json.hpp.What I’d change (high level)
std::unique_ptr(with custom deleters where needed) or small wrapper types for FFmpeg handles and for the packet, so cleanup is uniform and constructor failure is easier to make leak-free.LaserData,std::optional, or smart pointers with documented ownership; same forLaprelative to the Beastsessionlifetime.Ask to maintainers
h264decoderonly first)?If this sounds good, I’ll prepare a minimal, testable PR (with build/runtime validation as you require in CONTRIBUTING) starting from the area you indicate first.
Thanks for considering it.
@jmplaza
Beta Was this translation helpful? Give feedback.
All reactions