Skip to content

Commit

Permalink
Fix singleton memory leaks
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Nobles <[email protected]>
  • Loading branch information
Nick Nobles committed May 15, 2024
1 parent 2647323 commit bb46b68
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion runtime/Cpp/runtime/src/atn/ATNDeserializationOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ATNDeserializationOptions::ATNDeserializationOptions(ATNDeserializationOptions *
_generateRuleBypassTransitions(options->_generateRuleBypassTransitions) {}

const ATNDeserializationOptions& ATNDeserializationOptions::getDefaultOptions() {
static const ATNDeserializationOptions* const defaultOptions = new ATNDeserializationOptions();
static const std::unique_ptr<const ATNDeserializationOptions> defaultOptions = std::make_unique<const ATNDeserializationOptions>();
return *defaultOptions;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ struct <lexer.name; format = "cap">StaticData final {
#if ANTLR4_USE_THREAD_LOCAL_CACHE
static thread_local
#endif
<lexer.name; format = "cap">StaticData *<lexer.grammarName; format = "lower">LexerStaticData = nullptr;
std::unique_ptr\<<lexer.name; format = "cap">StaticData> <lexer.grammarName; format = "lower">LexerStaticData = nullptr;

void <lexer.grammarName; format = "lower">LexerInitialize() {
#if ANTLR4_USE_THREAD_LOCAL_CACHE
Expand Down Expand Up @@ -175,7 +175,7 @@ void <lexer.grammarName; format = "lower">LexerInitialize() {
}
);
<atn>
<lexer.grammarName; format = "lower">LexerStaticData = staticData.release();
<lexer.grammarName; format = "lower">LexerStaticData = std::move(staticData);
}

}
Expand Down Expand Up @@ -380,7 +380,7 @@ struct <parser.name; format = "cap">StaticData final {
#if ANTLR4_USE_THREAD_LOCAL_CACHE
static thread_local
#endif
<parser.name; format = "cap">StaticData *<parser.grammarName; format = "lower">ParserStaticData = nullptr;
std::unique_ptr\<<parser.name; format = "cap">StaticData> <parser.grammarName; format = "lower">ParserStaticData = nullptr;

void <parser.grammarName; format = "lower">ParserInitialize() {
#if ANTLR4_USE_THREAD_LOCAL_CACHE
Expand All @@ -402,7 +402,7 @@ void <parser.grammarName; format = "lower">ParserInitialize() {
}
);
<atn>
<parser.grammarName; format = "lower">ParserStaticData = staticData.release();
<parser.grammarName; format = "lower">ParserStaticData = std::move(staticData);
}

}
Expand Down

0 comments on commit bb46b68

Please sign in to comment.