Skip to content

Conversation

@RadixSeven
Copy link
Contributor

I fixed a memory leak by moving to unique_ptr and also moved the initialization in the constructors to their initialization lists.

I considered having conditional compilation for C++98 to use auto_ptr, but the makefile specifies C++0x so I decided against it.

Eric Moyer added 3 commits December 13, 2015 12:22
When code like:

    intervalTree a; //Fill a
    intervalTree b; //Fill b
    b=a;

was executed, b's contents would not get deleted before being
overwritten by a copy of a's contents. Though I could have fixed the
bug directly, I fixed that class of bugs by making left and right
unique_ptr. Changing to unique_ptr also simplified the code allowing
the destructor to be defaulted and the assignment code for left and
right to be reduced to two assignments. (If we were using C++ 14 the
copyTree helper function could have been omitted too since it has
make_unique.)
ekg added a commit that referenced this pull request Dec 13, 2015
@ekg ekg merged commit 93d9da5 into ekg:master Dec 13, 2015
@RadixSeven RadixSeven deleted the fix_memory_leak branch December 13, 2015 18:06
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