From 6596d638ff97a0cb329c811ff625e15cc71bb90d Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Sat, 6 Aug 2016 17:54:21 +0300 Subject: [PATCH] Fixed the type map for std::string to also destroy the allocator. Signed-off-by: Dimitar Dobrev --- src/Generator/Types/Std/Stdlib.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Generator/Types/Std/Stdlib.cs b/src/Generator/Types/Std/Stdlib.cs index 11dc2eb1..efdaa2f5 100644 --- a/src/Generator/Types/Std/Stdlib.cs +++ b/src/Generator/Types/Std/Stdlib.cs @@ -76,10 +76,13 @@ namespace CppSharp.Types.Std } else { + string varAllocator = "__allocator" + ctx.ParameterIndex; string varBasicString = "__basicString" + ctx.ParameterIndex; - ctx.SupportBefore.WriteLine("using (var {0} = new {1}({2}, new {3}()))", + ctx.SupportBefore.WriteLine("using (var {0} = new {1}())", + varAllocator, allocator.Visit(typePrinter)); + ctx.SupportBefore.WriteLine("using (var {0} = new {1}({2}, {3}))", varBasicString, basicString.Visit(typePrinter), - ctx.Parameter.Name, allocator.Visit(typePrinter)); + ctx.Parameter.Name, varAllocator); ctx.SupportBefore.WriteStartBraceIndent(); ctx.Return.Write("{0}.{1}", varBasicString, Helpers.InstanceIdentifier); ctx.HasCodeBlock = true;