From 829b7a46091833e5db305cf64f6f0d374a1df990 Mon Sep 17 00:00:00 2001 From: Eric Mellino Date: Mon, 5 Jun 2017 22:29:07 -0700 Subject: [PATCH] Make sure to return the rented array in DrawList.cs --- src/ImGui.NET/DrawList.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ImGui.NET/DrawList.cs b/src/ImGui.NET/DrawList.cs index 5e55c85..920821a 100644 --- a/src/ImGui.NET/DrawList.cs +++ b/src/ImGui.NET/DrawList.cs @@ -59,6 +59,7 @@ namespace ImGuiNET public unsafe void AddText(Vector2 position, string text, uint color) { + // Consider using stack allocation if a newer version of Encoding is used (with byte* overloads). int bytes = Encoding.UTF8.GetByteCount(text); byte[] tempBytes = ArrayPool.Shared.Rent(bytes); Encoding.UTF8.GetBytes(text, 0, text.Length, tempBytes, 0); @@ -66,6 +67,7 @@ namespace ImGuiNET { ImGuiNative.ImDrawList_AddText(_nativeDrawList, position, color, bytePtr, bytePtr + bytes); } + ArrayPool.Shared.Return(tempBytes); } public void PushClipRect(Vector2 min, Vector2 max, bool intersectWithCurrentClipRect)