File tree Expand file tree Collapse file tree 2 files changed +10
-11
lines changed
BizHawk.Emulation.Cores/Consoles/Nintendo/3DS Expand file tree Collapse file tree 2 files changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -287,24 +287,24 @@ static bool TryWaitForFileToVanish(string path)
287
287
}
288
288
289
289
/// <summary>creates span over <paramref name="length"/> octets starting at <paramref name="ptr"/></summary>
290
+ /// <remarks>returns empty span if <paramref name="ptr"/> is the null pointer (<see cref="IntPtr.Zero"/>)</remarks>
290
291
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
291
292
public static unsafe Span < byte > UnsafeSpanFromPointer ( IntPtr ptr , int length )
292
- {
293
- return new ( pointer : ptr . ToPointer ( ) , length : length ) ;
294
- }
293
+ => ptr == IntPtr . Zero ? [ ] : new ( pointer : ptr . ToPointer ( ) , length : length ) ;
295
294
296
295
#if false // unused
297
296
/// <summary>
298
297
/// creates span over <paramref name="count"/><c> * sizeof(</c><typeparamref name="T"/><c>)</c> octets
299
298
/// starting at <paramref name="ptr"/>
300
299
/// </summary>
301
- /// <remarks>uses native endianness and <paramref name="ptr"/> must be aligned (else UB)</remarks>
300
+ /// <remarks>
301
+ /// uses native endianness and <paramref name="ptr"/> must be aligned (else UB);
302
+ /// returns empty span if <paramref name="ptr"/> is the null pointer (<see cref="IntPtr.Zero"/>)
303
+ /// </remarks>
302
304
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
303
305
public static unsafe Span < T > UnsafeSpanFromPointerAligned < T > ( IntPtr ptr , int count )
304
306
where T : unmanaged
305
- {
306
- return new ( pointer : ptr . ToPointer ( ) , length : count * sizeof ( T ) ) ;
307
- }
307
+ => ptr == IntPtr . Zero ? [ ] : new ( pointer : ptr . ToPointer ( ) , length : count * sizeof ( T ) ) ;
308
308
#endif
309
309
310
310
public static void WriteByteBuffer ( this BinaryWriter bw , byte [ ] ? data )
Original file line number Diff line number Diff line change @@ -72,10 +72,9 @@ public EncoreMMU(IntPtr context)
72
72
}
73
73
74
74
private Span < byte > GetPage ( uint addr )
75
- {
76
- var pagePointer = _core . Encore_GetPagePointer ( _context , addr ) ;
77
- return pagePointer == IntPtr . Zero ? [ ] : Util. UnsafeSpanFromPointer ( pagePointer , ( int ) ( ENCORE_PAGE_SIZE - ( addr & ENCORE_PAGE_MASK ) ) ) ;
78
- }
75
+ => Util . UnsafeSpanFromPointer (
76
+ ptr : _core . Encore_GetPagePointer ( _context , addr : addr ) ,
77
+ length : ( int ) ( ENCORE_PAGE_SIZE - ( addr & ENCORE_PAGE_MASK ) ) ) ;
79
78
80
79
public override byte PeekByte ( long addr )
81
80
{
You can’t perform that action at this time.
0 commit comments