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

Using C++11 smart pointers and references rather than C raw pointers. #97

Closed
kalouantonis opened this issue Oct 1, 2014 · 2 comments
Closed

Comments

@kalouantonis
Copy link

Hey guys,

So, I was looking over the source and there seems to be a large use of raw pointers which could be avoided through the use of smart pointers. These will define ownership for every object in the game while also avoiding manual deallocation and possible memory leaks or double frees.

For example, in Game.h:131 a map object is stored as a raw pointer and passed to objects. This could be converted to shared_ptr's or even better stored as a unique_ptr in the Game class and delegated as references. In this case, this would work quite well, as the objects that require it ensure that it is passed through the constructor, so it is allowed to be stored as a reference in the class instance.

If you're interested in making this switch, which I personally think will improve the projects architecture and remove memory issues later down the line, let me know. I'm more than willing to do the all initial work.

Thanks.

@Elyotna
Copy link
Owner

Elyotna commented Oct 1, 2014

Definitly a good idea, I haven't put many efforts into it because I focused on functionnalities & reversing, but you're more than welcome to clear the code up.

@Querijn
Copy link

Querijn commented Oct 1, 2014

The PathNode::nodeTable is handled for optimisation reasons (collision branch), but you're free to change other references.

@Querijn Querijn closed this as completed Oct 1, 2014
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

No branches or pull requests

3 participants