forked from smartdevicelink/sdl_core
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Fix/SDL memory leaks #41
Open
SNiukalov
wants to merge
8
commits into
develop
Choose a base branch
from
fix/sdl_memory_leaks
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ae8d848
SDL fix memory leaks
5a07552
UTs fix memory leaks
5f9174c
SDL fix accumulation memory
be4a738
fixup! UTs fix memory leaks
ed572e6
fixup! SDL fix memory leaks
dff6e3e
fixup! SDL fix memory leaks
e62a8eb
fixup! SDL fix memory leaks
b985f83
fixup! SDL fix memory leaks
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,66 @@ using ::testing::Return; | |
using ::testing::ReturnPointee; | ||
using ::testing::ReturnRef; | ||
|
||
ResumptionDataTest::~ResumptionDataTest() { | ||
for (auto& submenu : test_submenu_map) { | ||
delete submenu.second; | ||
} | ||
|
||
test_submenu_map.clear(); | ||
|
||
for (auto& command : test_commands_map) { | ||
delete command.second; | ||
} | ||
|
||
test_commands_map.clear(); | ||
|
||
for (auto& choiceset : test_choiceset_map) { | ||
delete choiceset.second; | ||
} | ||
|
||
test_choiceset_map.clear(); | ||
|
||
if (help_prompt_) { | ||
delete help_prompt_; | ||
help_prompt_ = nullptr; | ||
} | ||
|
||
if (timeout_prompt_) { | ||
delete timeout_prompt_; | ||
timeout_prompt_ = nullptr; | ||
} | ||
|
||
if (vr_help_) { | ||
delete vr_help_; | ||
vr_help_ = nullptr; | ||
} | ||
|
||
if (vr_help_title_) { | ||
delete vr_help_title_; | ||
vr_help_title_ = nullptr; | ||
} | ||
|
||
if (vr_synonyms_) { | ||
delete vr_synonyms_; | ||
vr_synonyms_ = nullptr; | ||
} | ||
|
||
if (keyboard_props_) { | ||
delete keyboard_props_; | ||
keyboard_props_ = nullptr; | ||
} | ||
|
||
if (menu_title_) { | ||
delete menu_title_; | ||
menu_title_ = nullptr; | ||
} | ||
|
||
if (menu_icon_) { | ||
delete menu_icon_; | ||
menu_icon_ = nullptr; | ||
} | ||
} | ||
|
||
void ResumptionDataTest::CheckSavedApp(sm::SmartObject& resume_app_list) { | ||
EXPECT_EQ(policy_app_id_, resume_app_list[am::strings::app_id].asString()); | ||
EXPECT_EQ(grammar_id_, resume_app_list[am::strings::grammar_id].asUInt()); | ||
|
@@ -442,7 +502,17 @@ void ResumptionDataTest::SetMenuTitleAndIcon() { | |
|
||
sm::SmartObject sm_title; | ||
sm_title = "test title"; | ||
|
||
if (menu_title_) { | ||
delete menu_title_; | ||
} | ||
|
||
menu_title_ = new sm::SmartObject(sm_title); | ||
|
||
if (menu_icon_) { | ||
delete menu_icon_; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @SNiukalov Smart pointers for all such items? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @AByzhynar |
||
} | ||
|
||
menu_icon_ = new sm::SmartObject(sm_icon); | ||
} | ||
|
||
|
@@ -456,14 +526,24 @@ void ResumptionDataTest::SetHelpAndTimeoutPrompt() { | |
help_prompt[i][am::strings::text] = "help prompt name" + std::string(numb); | ||
help_prompt[i][am::strings::type] = SpeechCapabilities::PRE_RECORDED; | ||
} | ||
|
||
if (help_prompt_) { | ||
delete help_prompt_; | ||
} | ||
|
||
help_prompt_ = new sm::SmartObject(help_prompt); | ||
|
||
for (uint i = 0; i < tts_chunks_count; ++i) { | ||
char numb[12]; | ||
std::snprintf(numb, 12, "%d", i); | ||
timeout_prompt[i][am::strings::text] = "timeout test" + std::string(numb); | ||
timeout_prompt[i][am::strings::type] = SpeechCapabilities::SC_TEXT; | ||
} | ||
|
||
if (timeout_prompt_) { | ||
delete timeout_prompt_; | ||
} | ||
|
||
timeout_prompt_ = new sm::SmartObject(timeout_prompt); | ||
} | ||
|
||
|
@@ -479,7 +559,16 @@ void ResumptionDataTest::SetVRHelpTitle() { | |
vr_help[i][am::strings::position] = i; | ||
} | ||
|
||
if (vr_help_) { | ||
delete vr_help_; | ||
} | ||
|
||
vr_help_ = new sm::SmartObject(vr_help); | ||
|
||
if (vr_help_title_) { | ||
delete vr_help_title_; | ||
} | ||
|
||
vr_help_title_ = new sm::SmartObject(vr_help_title); | ||
} | ||
|
||
|
@@ -591,6 +680,11 @@ void ResumptionDataTest::SetKeyboardProperties() { | |
keyboard[am::strings::auto_complete_text] = "complete"; | ||
keyboard[am::strings::limited_character_list][0] = "y"; | ||
keyboard[am::strings::limited_character_list][1] = "n"; | ||
|
||
if (keyboard_props_) { | ||
delete keyboard_props_; | ||
} | ||
|
||
keyboard_props_ = new sm::SmartObject(keyboard); | ||
} | ||
|
||
|
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SNiukalov why do we dlete only second item? Don't we clear the entire map?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AByzhynar
Fixed in:be4a738