From f440b7c1332b4d8ece20f9d3a2512a63df518496 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaigan=C3=A9sh=20Kumaran?= Date: Sat, 24 Sep 2022 21:31:39 +0530 Subject: [PATCH 1/3] Update CppCXCodeGenerator.cs --- .../ReswPlus.Core/CodeGenerators/CppCXCodeGenerator.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/VSExtension/ReswPlus.Core/CodeGenerators/CppCXCodeGenerator.cs b/src/VSExtension/ReswPlus.Core/CodeGenerators/CppCXCodeGenerator.cs index e3c1920..89be1ba 100644 --- a/src/VSExtension/ReswPlus.Core/CodeGenerators/CppCXCodeGenerator.cs +++ b/src/VSExtension/ReswPlus.Core/CodeGenerators/CppCXCodeGenerator.cs @@ -256,7 +256,9 @@ protected override void CppCreateFormatMethod(CodeStringBuilder builderCpp, stri builderCpp.AppendLine($"size_t needed = _swprintf_p(nullptr, 0, {localizationStr}->Data(), {formatParameters});"); builderCpp.AppendLine($"wchar_t *buffer = new wchar_t[needed + 1];"); builderCpp.AppendLine($"_swprintf_p(buffer, needed + 1, {localizationStr}->Data(), {formatParameters});"); - builderCpp.AppendLine($"return ref new String(buffer);"); + builderCpp.AppendLine($"auto const string = ref new String(buffer);"); + builderCpp.AppendLine($"delete[] buffer"); + builderCpp.AppendLine($"return string"); } } else From 08bfdf3ef51a5d1b251b7ab6ab53ffb3f962fef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaigan=C3=A9sh=20Kumaran?= Date: Sat, 24 Sep 2022 21:34:58 +0530 Subject: [PATCH 2/3] Update CppWinRTCodeGenerator.cs --- .../ReswPlus.Core/CodeGenerators/CppWinRTCodeGenerator.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/VSExtension/ReswPlus.Core/CodeGenerators/CppWinRTCodeGenerator.cs b/src/VSExtension/ReswPlus.Core/CodeGenerators/CppWinRTCodeGenerator.cs index fec9d1b..bba4690 100644 --- a/src/VSExtension/ReswPlus.Core/CodeGenerators/CppWinRTCodeGenerator.cs +++ b/src/VSExtension/ReswPlus.Core/CodeGenerators/CppWinRTCodeGenerator.cs @@ -273,7 +273,9 @@ protected override void CppCreateFormatMethod(CodeStringBuilder builderCpp, stri builderCpp.AppendLine($"size_t needed = _swprintf_p(nullptr, 0, {localizationStr}.c_str(), {formatParameters});"); builderCpp.AppendLine($"wchar_t *buffer = new wchar_t[needed + 1];"); builderCpp.AppendLine($"_swprintf_p(buffer, needed + 1, {localizationStr}.c_str(), {formatParameters});"); - builderCpp.AppendLine($"return hstring(buffer);"); + builderCpp.AppendLine($"hstring const string{ buffer };"); + builderCpp.AppendLine($"delete[] buffer;"); + builderCpp.AppendLine($"return string;"); } } else From 937f6b678852b0c9457d86973465722e8de73afc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaigan=C3=A9sh=20Kumaran?= Date: Sat, 24 Sep 2022 21:37:09 +0530 Subject: [PATCH 3/3] Update CppCXCodeGenerator.cs --- .../ReswPlus.Core/CodeGenerators/CppCXCodeGenerator.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/VSExtension/ReswPlus.Core/CodeGenerators/CppCXCodeGenerator.cs b/src/VSExtension/ReswPlus.Core/CodeGenerators/CppCXCodeGenerator.cs index 89be1ba..1ea5078 100644 --- a/src/VSExtension/ReswPlus.Core/CodeGenerators/CppCXCodeGenerator.cs +++ b/src/VSExtension/ReswPlus.Core/CodeGenerators/CppCXCodeGenerator.cs @@ -257,8 +257,8 @@ protected override void CppCreateFormatMethod(CodeStringBuilder builderCpp, stri builderCpp.AppendLine($"wchar_t *buffer = new wchar_t[needed + 1];"); builderCpp.AppendLine($"_swprintf_p(buffer, needed + 1, {localizationStr}->Data(), {formatParameters});"); builderCpp.AppendLine($"auto const string = ref new String(buffer);"); - builderCpp.AppendLine($"delete[] buffer"); - builderCpp.AppendLine($"return string"); + builderCpp.AppendLine($"delete[] buffer;"); + builderCpp.AppendLine($"return string;"); } } else