Skip to content

refactor: replace 'throw new' with value-based exceptions for CThreadErr#36

Open
kirito632 wants to merge 1 commit into
osdldbt:mainfrom
kirito632:fix/value-based-exceptions
Open

refactor: replace 'throw new' with value-based exceptions for CThreadErr#36
kirito632 wants to merge 1 commit into
osdldbt:mainfrom
kirito632:fix/value-based-exceptions

Conversation

@kirito632
Copy link
Copy Markdown

The codebase uses throw new CThreadErr(...) which allocates the
exception object on the heap. This requires catch blocks to manually
delete the pointer to avoid memory leaks. Several catch blocks were
missing this delete.

Replace with value-based throws and catch by const CThreadErr&,
letting the compiler manage the exception object lifetime automatically.

Changes:

  • src/Driver/Driver.cpp
  • src/interfaces/MEESUT.cpp
  • src/MarketExchange/MarketExchange.cpp
  • src/BrokerageHouse/BrokerageHouse.cpp

Using 'throw new CThreadErr' requires manual memory management in catch
blocks. Missing 'delete' on the exception pointer causes memory leaks.

Replace with value-based throws and catch by const reference, letting
the compiler manage exception object lifetime automatically.
Copy link
Copy Markdown
Contributor

@markwkm markwkm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good to me. It might take me a little more time to merge it in.

@kirito632
Copy link
Copy Markdown
Author

Thank you for the review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants