Skip to content

Commit

Permalink
Fixed compilation on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
prikolium-cfx committed May 28, 2024
1 parent ca2a478 commit 59c1865
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions MsgPack/Detail/StringComparisonHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,25 @@

namespace CitizenFX.MsgPack.Detail
{
[StructLayout(LayoutKind.Explicit)]
internal unsafe struct StringComparisonHelper
{
[FieldOffset(0)] public fixed byte u8[8];
[FieldOffset(0)] public fixed ushort u16[4];
[FieldOffset(0)] public fixed uint u32[2];
[FieldOffset(0)] public fixed ulong u64[1];
[StructLayout(LayoutKind.Explicit)]
internal unsafe struct StringComparisonHelper
{
[FieldOffset(0)] public fixed byte u8[8];
[FieldOffset(0)] public fixed ushort u16[4];
[FieldOffset(0)] public fixed uint u32[2];
[FieldOffset(0)] public fixed ulong u64[1];

public StringComparisonHelper(string str, int offset = 0)
{
int length = str.Length - offset;
if (length > 8)
length = 8;
public StringComparisonHelper(string str, int offset = 0)
{
fixed (byte* pU8 = u8)
{
int length = str.Length - offset;
if (length > 8)
length = 8;

for (int i = 0; i < length; ++i)
u8[i] = (byte)str[i - offset];
}
}
}
for (int i = 0; i < length; ++i)
pU8[i] = (byte)str[i + offset];
}
}
}
}

0 comments on commit 59c1865

Please sign in to comment.