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)
287287 }
288288
289289 /// <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>
290291 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
291292 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 ) ;
295294
296295#if false // unused
297296 /// <summary>
298297 /// creates span over <paramref name="count"/><c> * sizeof(</c><typeparamref name="T"/><c>)</c> octets
299298 /// starting at <paramref name="ptr"/>
300299 /// </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>
302304 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
303305 public static unsafe Span < T > UnsafeSpanFromPointerAligned < T > ( IntPtr ptr , int count )
304306 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 ) ) ;
308308#endif
309309
310310 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)
7272 }
7373
7474 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 ) ) ) ;
7978
8079 public override byte PeekByte ( long addr )
8180 {
You can’t perform that action at this time.
0 commit comments