checkpoint for real
This commit is contained in:
@@ -4,16 +4,10 @@ using System.Text;
|
||||
|
||||
namespace Foodsoft.Alpm
|
||||
{
|
||||
internal readonly struct UTF8Marshaler : ICustomMarshaler
|
||||
internal readonly struct UTF8InMarshaler : ICustomMarshaler
|
||||
{
|
||||
private static readonly UTF8Marshaler _instance = default;
|
||||
|
||||
// ReSharper disable once UnusedMember.Local
|
||||
// ReSharper disable once UnusedParameter.Local
|
||||
private static ICustomMarshaler GetInstance(string cookie)
|
||||
{
|
||||
return _instance;
|
||||
}
|
||||
private static readonly UTF8InMarshaler _instance = default;
|
||||
|
||||
|
||||
public void CleanUpManagedData(object managedObj) { }
|
||||
|
||||
@@ -35,13 +29,14 @@ namespace Foodsoft.Alpm
|
||||
var nb = Encoding.UTF8.GetMaxByteCount(s.Length);
|
||||
|
||||
var pMem = Marshal.AllocHGlobal(nb + 1);
|
||||
var pbMem = (byte*) pMem;
|
||||
var pbMem = (byte*) pMem;
|
||||
|
||||
int nbWritten;
|
||||
fixed (char* firstChar = s)
|
||||
{
|
||||
nbWritten = Encoding.UTF8.GetBytes(firstChar, s.Length, pbMem, nb);
|
||||
}
|
||||
|
||||
pbMem[nbWritten] = 0;
|
||||
return pMem;
|
||||
}
|
||||
@@ -50,5 +45,12 @@ namespace Foodsoft.Alpm
|
||||
{
|
||||
return Marshal.PtrToStringUTF8(pNativeData)!;
|
||||
}
|
||||
|
||||
// ReSharper disable once UnusedMember.Local
|
||||
// ReSharper disable once UnusedParameter.Local
|
||||
private static ICustomMarshaler GetInstance(string cookie)
|
||||
{
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user