@@ -14,7 +14,7 @@ namespace ZstdSharp
14
14
{
15
15
public static unsafe class UnsafeHelper
16
16
{
17
- public static void * PoisonMemory ( void * destination , int size )
17
+ public static void * PoisonMemory ( void * destination , ulong size )
18
18
{
19
19
memset ( destination , 0xCC , size ) ;
20
20
return destination ;
@@ -24,7 +24,7 @@ public static unsafe class UnsafeHelper
24
24
public static void * malloc ( uint size )
25
25
{
26
26
#if DEBUG
27
- return PoisonMemory ( ( void * ) Marshal . AllocHGlobal ( ( int ) size ) , ( int ) size ) ;
27
+ return PoisonMemory ( ( void * ) Marshal . AllocHGlobal ( ( int ) size ) , size ) ;
28
28
#else
29
29
return ( void * ) Marshal . AllocHGlobal ( ( int ) size ) ;
30
30
#endif
@@ -34,19 +34,17 @@ public static unsafe class UnsafeHelper
34
34
public static void * malloc ( ulong size )
35
35
{
36
36
#if DEBUG
37
- return PoisonMemory ( ( void * ) Marshal . AllocHGlobal ( ( int ) size ) , ( int ) size ) ;
37
+ return PoisonMemory ( ( void * ) Marshal . AllocHGlobal ( ( nint ) size ) , size ) ;
38
38
#else
39
- return ( void * ) Marshal . AllocHGlobal ( ( int ) size ) ;
39
+ return ( void * ) Marshal . AllocHGlobal ( ( nint ) size ) ;
40
40
#endif
41
41
}
42
42
43
43
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
44
44
public static void * calloc ( ulong num , ulong size )
45
45
{
46
- int total = ( int ) ( num * size ) ;
47
- var destination = ( void * ) Marshal . AllocHGlobal ( total ) ;
48
- //Unsafe.InitBlockUnaligned(destination, 0, (uint)total);
49
- //Ldloc(nameof(destination));
46
+ var total = num * size ;
47
+ var destination = ( void * ) Marshal . AllocHGlobal ( ( nint ) total ) ;
50
48
memset ( destination , 0 , total ) ;
51
49
return destination ;
52
50
}
0 commit comments