Skip to content

Commit 1eef5c8

Browse files
committed
Fix marshalling of string arrays.
* Affects only ImGui.Combo and ListBox.
1 parent 2e31c95 commit 1eef5c8

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/CodeGenerator/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,8 +660,8 @@ private static void EmitOverload(
660660
preCallLines.Add($" fixed (char* sPtr = s)");
661661
preCallLines.Add(" {");
662662
preCallLines.Add($" offset += Encoding.UTF8.GetBytes(sPtr, s.Length, {nativeArgName}_data + offset, {correctedIdentifier}_byteCounts[i]);");
663-
preCallLines.Add($" offset += 1;");
664663
preCallLines.Add($" {nativeArgName}_data[offset] = 0;");
664+
preCallLines.Add($" offset += 1;");
665665
preCallLines.Add(" }");
666666
preCallLines.Add("}");
667667

src/ImGui.NET/Generated/ImGui.gen.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ public static bool Combo(string label, ref int current_item, string[] items, int
7777
fixed (char* sPtr = s)
7878
{
7979
offset += Encoding.UTF8.GetBytes(sPtr, s.Length, native_items_data + offset, items_byteCounts[i]);
80-
offset += 1;
8180
native_items_data[offset] = 0;
81+
offset += 1;
8282
}
8383
}
8484
byte** native_items = stackalloc byte*[items.Length];
@@ -126,8 +126,8 @@ public static bool Combo(string label, ref int current_item, string[] items, int
126126
fixed (char* sPtr = s)
127127
{
128128
offset += Encoding.UTF8.GetBytes(sPtr, s.Length, native_items_data + offset, items_byteCounts[i]);
129-
offset += 1;
130129
native_items_data[offset] = 0;
130+
offset += 1;
131131
}
132132
}
133133
byte** native_items = stackalloc byte*[items.Length];
@@ -4901,8 +4901,8 @@ public static bool ListBox(string label, ref int current_item, string[] items, i
49014901
fixed (char* sPtr = s)
49024902
{
49034903
offset += Encoding.UTF8.GetBytes(sPtr, s.Length, native_items_data + offset, items_byteCounts[i]);
4904-
offset += 1;
49054904
native_items_data[offset] = 0;
4905+
offset += 1;
49064906
}
49074907
}
49084908
byte** native_items = stackalloc byte*[items.Length];
@@ -4950,8 +4950,8 @@ public static bool ListBox(string label, ref int current_item, string[] items, i
49504950
fixed (char* sPtr = s)
49514951
{
49524952
offset += Encoding.UTF8.GetBytes(sPtr, s.Length, native_items_data + offset, items_byteCounts[i]);
4953-
offset += 1;
49544953
native_items_data[offset] = 0;
4954+
offset += 1;
49554955
}
49564956
}
49574957
byte** native_items = stackalloc byte*[items.Length];

0 commit comments

Comments
 (0)