checkpoint for real

This commit is contained in:
2020-04-27 12:34:56 -04:00
parent 6ed92261ec
commit c1618deb83
31 changed files with 1429 additions and 626 deletions

View File

@@ -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;
}
}
}