Coding - Replace function-local new[]/delete[] with std::vector in TKernel(For CI testing) - #2
Closed
jijinbei wants to merge 2 commits into
Closed
Coding - Replace function-local new[]/delete[] with std::vector in TKernel(For CI testing)#2jijinbei wants to merge 2 commits into
jijinbei wants to merge 2 commits into
Conversation
…ernel Step 1 of MODERNIZATION_NOTES.md item Open-Cascade-SAS#10 (raw new/delete -> RAII). Targets only function-local arrays where Handle<> is not involved and the buffer never escapes the function (or its caller's scope through a copy). Total: 7 sites across 5 files; net diff -1 LOC plus implicit exception safety win. Files touched: TKernel/Message/Message_Msg.cxx (1 site, char[] for Sprintf) TKernel/NCollection/NCollection_BaseMap.cxx (1 site, int[] for stats) TKernel/OSD/OSD_Process.cxx (1 site, wchar_t[], Windows only) TKernel/OSD/OSD_Environment.cxx (1 site, wchar_t[], Windows only) TKernel/GTests/TCollection_ExtendedString_Test.cxx (3 sites, char[]) Pattern applied: char* p = new char[N]; ... delete[] p; becomes std::vector<char> p(N); ... use p.data() ... Where the OCCT API takes Standard_PCharacter& (lvalue ref to pointer), the data() pointer is bound to a named lvalue first. Skipped for later steps (member raw pointers, heavy pointer arithmetic): TKernel/OSD/OSD_SharedLibrary.cxx (myName is a class member) TKernel/NCollection/NCollection_UtfString.cxx (myWideBuffer member) TKMath/math/math_ComputeKronrodPointsAndWeights.cxx (s++/swap pointer arithmetic) Verified by running the full OpenCascadeGTest suite on Linux: 6717 PASS / 4 SKIP (unrelated zero-magnitude exception tests). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
jijinbei
force-pushed
the
modernize-raii-array-new
branch
from
April 19, 2026 19:50
b8f27d3 to
8ea9a8d
Compare
Single-line collapse of std::vector<char> ctor argument; matched the OCCT clang-format style. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Owner
Author
|
For CI testing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Scope
Handle<>is not involved and the buffer never escapes the function (or escapes through a copy)Pattern
Where the OCCT API takes
Standard_PCharacter&(lvalue ref to pointer),data()is bound to a named lvalue first.Files touched
TKernel/Message/Message_Msg.cxxchar[]forSprintfTKernel/NCollection/NCollection_BaseMap.cxxint[]for statsTKernel/OSD/OSD_Process.cxxwchar_t[], Windows onlyTKernel/OSD/OSD_Environment.cxxwchar_t[], Windows onlyTKernel/GTests/TCollection_ExtendedString_Test.cxxchar[]Skipped (later steps)
OSD_SharedLibrary.cxx—myNameis a class member (PIMPL-style refactor needed)NCollection_UtfString.cxx—myWideBufferis a class membermath_ComputeKronrodPointsAndWeights.cxx— heavys++/ pointer-swap arithmetic