1
0
mirror of https://github.com/oliverbooth/VpSharp synced 2024-11-10 02:35:42 +00:00

Mark GetStringLength static

This commit is contained in:
Oliver Booth 2022-11-30 00:46:31 +00:00
parent 2d8dc52c3e
commit f4c7bdad41
No known key found for this signature in database
GPG Key ID: 32A00B35503AF634

View File

@ -12,6 +12,16 @@ internal sealed class Utf8StringToManaged : ICustomMarshaler
return s_instance ??= new Utf8StringToManaged();
}
private static int GetStringLength(IntPtr ptr)
{
int offset;
for (offset = 0; Marshal.ReadByte(ptr, offset) != 0; offset++)
{
}
return offset;
}
public void CleanUpNativeData(IntPtr pNativeData)
{
// Do nothing. For some reason CleanUpNativeData is called for pointers that are not even created by the marshaler.
@ -33,16 +43,6 @@ internal sealed class Utf8StringToManaged : ICustomMarshaler
throw new NotImplementedException();
}
private int GetStringLength(IntPtr ptr)
{
int offset;
for (offset = 0; Marshal.ReadByte(ptr, offset) != 0; offset++)
{
}
return offset;
}
public object MarshalNativeToManaged(IntPtr pNativeData)
{
if (pNativeData == IntPtr.Zero)