Repository navigation
refactor(stodft): replace new[]/delete[] with std::vector in info_gatherv - #8149
Merged
Merged
Conversation
mohanchen
approved these changes
Oct 15, 2026
ABACUS-PR-BOT
left a comment
Collaborator
There was a problem hiding this comment.
Static review of b9acd92: no correctness regression identified in the ownership conversion or caller updates. No builds or runtime tests were run; CI retrieval was unavailable.
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.
What this PR does
Replace raw
new[]/delete[]withstd::vectorinsource/source_pw/module_stodft/sto_tool.h.Why
std::vectormanages memory automatically, removing the need for manualdelete[].std::vectorover rawnew/deletefor dynamic arrays".Changes
info_gatherv::nrecvandinfo_gatherv::displschanged fromint*tostd::vector<int>.std::vectorhandles cleanup.MPI_Allgathernow receivesnrecv.data()instead of raw pointer.#include <vector>tosto_tool.hbecausestd::vector<int>is now a member type ofinfo_gathervand member variables require complete types (forward declaration is not possible for template classes).source/source_pw/module_stodft/sto_elecond.cppto passnrecv.data()/displs.data()to the existingint*interfaces (gatherchi_op,Parallel_Common::gatherv_data).Verification performed
cmake --build build -j 8(withENABLE_LCAO=OFF,ENABLE_ELPA=OFFdue to local environment constraints)ctest --test-dir build -R MODULE_PW_Sto -VMODULE_PW_Sto_Tool_UTsPASSED (coverssto_tool.h)MODULE_PW_Sto_Hamilt_UTsPASSEDMODULE_PW_Sto_HSolver_UTsPASSEDpython3 tools/03_code_analysis/agent_governance_check.py --stagedstd::vector<int>is a member type and requires complete type, cannot forward declareDocumentation
No documentation update needed. This change is internal to
info_gathervand does not affect any public API, user-facing behavior, or input parameters.Checklist
#define private publicin tests.hppimplementation headersstd::vector::data()which is C++11)