Skip to content

Commit a91a2ea

Browse files
authored
Fix GlobalMemory.BStrToMemory (#479)
1 parent 61e3769 commit a91a2ea

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/Core/Silk.NET.Core/Native/GlobalMemory.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public sealed class GlobalMemory : IDisposable
1515
// Actual object
1616
private readonly object _memoryObject;
1717

18-
internal GlobalMemory(object memoryObject, int length)
18+
private GlobalMemory(object memoryObject, int length)
1919
{
2020
_memoryObject = memoryObject;
2121
Length = length;
@@ -177,21 +177,21 @@ private struct GCHandleByteArray : IGlobalMemory
177177
public nint Handle => GCHandle.AddrOfPinnedObject();
178178
}
179179

180-
private struct HGlobal : IGlobalMemory
180+
private readonly struct HGlobal : IGlobalMemory
181181
{
182182
public HGlobal(int length) => Handle = Marshal.AllocHGlobal(length);
183183
public HGlobal(nint val) => Handle = val;
184184
public nint Handle { get; }
185185
}
186186

187-
private struct BStr : IGlobalMemory
187+
private readonly struct BStr : IGlobalMemory
188188
{
189189
public BStr(int length) => Handle = SilkMarshal.AllocBStr(length);
190190
public BStr(nint val) => Handle = val;
191191
public nint Handle { get; }
192192
}
193193

194-
private struct Other : IGlobalMemory
194+
private readonly struct Other : IGlobalMemory
195195
{
196196
// used for "unsafe" marshalling of a pointer to our neat GlobalMemory class if that's your thing.
197197
public Other(nint val) => Handle = val;

src/Core/Silk.NET.Core/Native/SilkMarshal.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ public static GlobalMemory HGlobalToMemory(nint hGlobal, int length)
464464
/// <param name="length">The length of this BStr in bytes.</param>
465465
/// <returns>An object representing this BStr.</returns>
466466
public static GlobalMemory BStrToMemory(nint bStr, int length)
467-
=> GlobalMemory.FromHGlobal(bStr, length);
467+
=> GlobalMemory.FromBStr(bStr, length);
468468

469469
/// <summary>
470470
/// Gets a <see cref="GlobalMemory"/> object representing this pointer.

0 commit comments

Comments
 (0)