Skip to content

Commit 85d01be

Browse files
zaafarmellinoe
authored andcommitted
minor fixup: updated util function signature.
1 parent 93d375a commit 85d01be

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/ImGui.NET/ImGui.Manual.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ private static Vector2 CalcTextSizeImpl(
403403
{
404404

405405
int textToCopyLen = length.HasValue ? length.Value : text.Length;
406-
textByteCount = Util.CalcUtf8(text, start, textToCopyLen);
406+
textByteCount = Util.CalcSizeInUtf8(text, start, textToCopyLen);
407407
if (textByteCount > Util.StackAllocationSizeLimit)
408408
{
409409
nativeTextStart = Util.Allocate(textByteCount + 1);
@@ -414,7 +414,7 @@ private static Vector2 CalcTextSizeImpl(
414414
nativeTextStart = nativeTextStackBytes;
415415
}
416416

417-
int nativeTextOffset = Util.GetUtf8(text, nativeTextStart, textByteCount, start, textToCopyLen);
417+
int nativeTextOffset = Util.GetUtf8(text, start, textToCopyLen, nativeTextStart, textByteCount);
418418
nativeTextStart[nativeTextOffset] = 0;
419419
nativeTextEnd = nativeTextStart + nativeTextOffset;
420420
}

src/ImGui.NET/Util.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ internal static bool AreStringsEqual(byte* a, int aLength, byte* b)
3232
}
3333

3434
internal static byte* Allocate(int byteCount) => (byte*)Marshal.AllocHGlobal(byteCount);
35+
3536
internal static void Free(byte* ptr) => Marshal.FreeHGlobal((IntPtr)ptr);
36-
internal static int CalcUtf8(string s, int start, int length)
37+
38+
internal static int CalcSizeInUtf8(string s, int start, int length)
3739
{
3840
if (start > s.Length - 1 || length > s.Length || start + length > s.Length)
3941
{
@@ -54,7 +56,7 @@ internal static int GetUtf8(string s, byte* utf8Bytes, int utf8ByteCount)
5456
}
5557
}
5658

57-
internal static int GetUtf8(string s, byte* utf8Bytes, int utf8ByteCount, int start = 0, int length = 0)
59+
internal static int GetUtf8(string s, int start, int length, byte* utf8Bytes, int utf8ByteCount)
5860
{
5961
fixed (char* utf16Ptr = s)
6062
{

0 commit comments

Comments
 (0)