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

[WIP] Modernization/migrate to smart pointers #49

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

SeanAlling-DojoFive
Copy link
Contributor

Blocked by PR #48

Start migrating code when applicable to:

  1. Use smart pointers
  2. Container objects

Goal is to reduce call of new/delete within source code.

To help validate a branch utilizing Valgrind was created. Cherry pick commit as needed for testing.

Running CTest configured for Valgrind will take significantly longer than normal to run.

Copy link
Owner

@sierrafoxtrot sierrafoxtrot left a comment

Choose a reason for hiding this comment

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

Thanks Sean. Definitely keen to move adler to smart pointers but I had some thoughts on the overall approach. Some comments made which describe those.

Happy to tackle when you've had a chance to rebase/merge of course.

/**
* The destructor.
*/
~memory_walker_adler16() override = default;

private:
Copy link
Owner

Choose a reason for hiding this comment

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

This inclusion of private here is intentional. The idea is that the headers are written from a template and in a very structured way. Rather than mysteriously move the constructor to the bottom of the header, it's left in the usual spot as a prompt (to the lib user especially) that the create method should be used.

/**
* The destructor.
*/
~memory_walker_adler32() override = default;

private:
Copy link
Owner

Choose a reason for hiding this comment

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

This is intentional, same as in adler16.h above.

@@ -56,8 +56,8 @@ srecord::input_filter_message_adler32::process(const memory &input,
// lowest address to highest. (Holes are ignored, not filled,
// warning issued already.)
//
memory_walker_adler32::pointer w =
memory_walker_adler32::create();
auto w = std::make_shared<memory_walker_adler32>();
Copy link
Owner

Choose a reason for hiding this comment

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

Definitely keen to move to smart pointers. I should have picked these up when I moved from boost to std share pointers elsewhere.

However, I'd rather move the creation of the smart pointer into the create method in the class(es). My worry is that someone using libsrecord won't get the benefit or more importantly may mix smart and non-smart pointers if they are using base and library code from the project.

@sierrafoxtrot
Copy link
Owner

Hi Sean. Apologies for falling behind but did you still want to move forward with this one?

@SeanAlling-DojoFive
Copy link
Contributor Author

I have been a little busy with life events recently. Will be coming back to this in a couple weeks.

@sierrafoxtrot
Copy link
Owner

Completely understand. Nothing but empathy from me on that one. I hope all is well.

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