mirror of
https://github.com/oliverbooth/VpSharp
synced 2024-11-10 02:15:41 +00:00
Mark GetStringLength static
This commit is contained in:
parent
2d8dc52c3e
commit
f4c7bdad41
@ -12,6 +12,16 @@ internal sealed class Utf8StringToManaged : ICustomMarshaler
|
|||||||
return s_instance ??= new Utf8StringToManaged();
|
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)
|
public void CleanUpNativeData(IntPtr pNativeData)
|
||||||
{
|
{
|
||||||
// Do nothing. For some reason CleanUpNativeData is called for pointers that are not even created by the marshaler.
|
// 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();
|
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)
|
public object MarshalNativeToManaged(IntPtr pNativeData)
|
||||||
{
|
{
|
||||||
if (pNativeData == IntPtr.Zero)
|
if (pNativeData == IntPtr.Zero)
|
||||||
|
Loading…
Reference in New Issue
Block a user