Skip to content
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

Convert raw pointers to smart pointers #316

Merged

Conversation

sbaldu
Copy link
Collaborator

@sbaldu sbaldu commented May 30, 2023

All the raw pointers used in the library have been converted to smart pointers (issue #234 ).

@github-actions github-actions bot added core something about core test Something about test labels May 30, 2023
@ghost
Copy link

ghost commented May 30, 2023

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

@sbaldu sbaldu marked this pull request as draft May 31, 2023 04:32
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

Cppcheck (reported by Codacy) found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.

@sbaldu sbaldu requested review from ZigRazor and nrkramer May 31, 2023 08:42
@sbaldu sbaldu marked this pull request as ready for review May 31, 2023 08:42
@codecov
Copy link

codecov bot commented May 31, 2023

Codecov Report

Merging #316 (b6a73fc) into master (5fc8449) will decrease coverage by 0.45%.
The diff coverage is 97.93%.

@@            Coverage Diff             @@
##           master     #316      +/-   ##
==========================================
- Coverage   97.59%   97.15%   -0.45%     
==========================================
  Files          53       54       +1     
  Lines        7487     7587     +100     
==========================================
+ Hits         7307     7371      +64     
- Misses        180      216      +36     
Flag Coverage Δ
unittests 97.15% <97.93%> (-0.45%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
include/Partitioning/CoordinatedPartitionState.hpp 75.63% <0.00%> (ø)
include/Partitioning/Partition.hpp 100.00% <ø> (ø)
include/Utility/Typedef.hpp 100.00% <ø> (ø)
test/DirectedEdgeTest.cpp 100.00% <ø> (ø)
test/DirectedWeightedEdgeTest.cpp 100.00% <ø> (ø)
test/UndirectedEdgeTest.cpp 100.00% <ø> (ø)
test/UndirectedWeightedEdgeTest.cpp 100.00% <ø> (ø)
test/main.cpp 100.00% <ø> (ø)
include/Partitioning/WeightBalancedLibra.hpp 74.35% <66.66%> (-3.57%) ⬇️
include/Graph/Graph.hpp 94.88% <93.41%> (-1.77%) ⬇️
... and 40 more

@ZigRazor
Copy link
Owner

I'm scared about memory leak with shared_ptr stack overflow reference.
Can you do some check reporting the results?

I know that can be a heavy work, but I think is necessary to ensure a good quality with this rework.

Maybe can be usefull to add example, and test memory ( with valgrind ) with these example.

@sbaldu
Copy link
Collaborator Author

sbaldu commented May 31, 2023

I'm scared about memory leak with shared_ptr stack overflow reference. Can you do some check reporting the results?

I know that can be a heavy work, but I think is necessary to ensure a good quality with this rework.

Maybe can be usefull to add example, and test memory ( with valgrind ) with these example.

I have removed all the calls to new in the test files and now if I run test_exe inside valgrind it doesn't show any leaks.
Is this enough or do we want do to some more thorough checks?
I could do like in the stack overflow example, insert some print-outs in the destructors and make sure that they are all called correctly.

@ZigRazor
Copy link
Owner

Better do more checks.
Your suggested solution is ok.

Thanks in advance

Fix typo in benchmark FloydWarshall
@sbaldu sbaldu force-pushed the feature_smart_pointers_keep_interface branch from 083cdd8 to 57dc2a4 Compare May 31, 2023 14:48
@sbaldu
Copy link
Collaborator Author

sbaldu commented May 31, 2023

Better do more checks. Your suggested solution is ok.

Thanks in advance

I've run all the tests singularly with valgrind and I didn't find any leaks. Also with the fsanitize=leak flag they compiled and run fine.
As I mentioned I also put print-outs in the destructors, and the memory allocated for the edges and the nodes seemed to be freed correctly.

I think that it looks safe. Are there any more tests that you think we should do to make sure?

@ZigRazor
Copy link
Owner

ZigRazor commented Jun 1, 2023

Ok, it's fine!

@ZigRazor ZigRazor merged commit 4569d22 into ZigRazor:master Jun 1, 2023
@ZigRazor ZigRazor linked an issue Jun 1, 2023 that may be closed by this pull request
@ZigRazor ZigRazor mentioned this pull request Jun 1, 2023
@sbaldu sbaldu deleted the feature_smart_pointers_keep_interface branch September 27, 2023 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core something about core test Something about test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Smart Pointers use
2 participants