Skip to content

Commit

Permalink
Native -> Unsafe
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-st committed May 11, 2021
1 parent d367bca commit 36353a7
Show file tree
Hide file tree
Showing 186 changed files with 193 additions and 186 deletions.
15 changes: 8 additions & 7 deletions src/Sandbox/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.IO;
using Zstd.Extern;
using ZstdSharp;
using ZstdSharp.Unsafe;

namespace Sandbox
{
Expand Down Expand Up @@ -36,24 +37,24 @@ static void Decompress()

static unsafe void Test1()
{
var cctx = ZstdSharp.Methods.ZSTD_createCCtx();
var dctx = ZstdSharp.Methods.ZSTD_createDCtx();
var cctx = Methods.ZSTD_createCCtx();
var dctx = Methods.ZSTD_createDCtx();

var src = File.ReadAllBytes("dickens");
var dest = new byte[ZstdSharp.Methods.ZSTD_compressBound((nuint) src.Length)];
var dest = new byte[Methods.ZSTD_compressBound((nuint) src.Length)];
var uncompressed = new byte[src.Length];
fixed (byte* dstPtr = dest)
fixed (byte* srcPtr = src)
fixed (byte* uncompressedPtr = uncompressed)
{
var compressedLength = ZstdSharp.Methods.ZSTD_compressCCtx(cctx, dstPtr, (nuint) dest.Length, srcPtr, (nuint) src.Length,
var compressedLength = Methods.ZSTD_compressCCtx(cctx, dstPtr, (nuint) dest.Length, srcPtr, (nuint) src.Length,
level);

var decompressedLength = ZstdSharp.Methods.ZSTD_decompressDCtx(dctx, uncompressedPtr, (nuint) uncompressed.Length, dstPtr, compressedLength);
var decompressedLength = Methods.ZSTD_decompressDCtx(dctx, uncompressedPtr, (nuint) uncompressed.Length, dstPtr, compressedLength);
Console.WriteLine($"{compressedLength} {decompressedLength} {src.Length}");
}
ZstdSharp.Methods.ZSTD_freeCCtx(cctx);
ZstdSharp.Methods.ZSTD_freeDCtx(dctx);
Methods.ZSTD_freeCCtx(cctx);
Methods.ZSTD_freeDCtx(dctx);
}

static unsafe void Test2()
Expand Down
1 change: 1 addition & 0 deletions src/ZstdSharp.Benchmark/Benchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using Zstd.Extern;
using ZstdSharp.Unsafe;

namespace ZstdSharp.Benchmark
{
Expand Down
1 change: 1 addition & 0 deletions src/ZstdSharp.Test/ZstdNetTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Text;
using System.Threading;
using Xunit;
using ZstdSharp.Unsafe;

namespace ZstdSharp.Test
{
Expand Down
2 changes: 1 addition & 1 deletion src/ZstdSharp.Test/ZstdTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using Xunit;
using Zstd.Extern;
using ZstdSharp.Unsafe;

namespace ZstdSharp.Test
{
Expand Down
1 change: 1 addition & 0 deletions src/ZstdSharp/Compressor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using ZstdSharp.Unsafe;

namespace ZstdSharp
{
Expand Down
1 change: 1 addition & 0 deletions src/ZstdSharp/Decompressor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using ZstdSharp.Unsafe;

namespace ZstdSharp
{
Expand Down
1 change: 1 addition & 0 deletions src/ZstdSharp/DictBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using ZstdSharp.Unsafe;

namespace ZstdSharp
{
Expand Down
2 changes: 1 addition & 1 deletion src/ZstdSharp/ThrowHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using ZstdSharp.Unsafe;

namespace ZstdSharp
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using static ZstdSharp.UnsafeHelper;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
public static unsafe partial class Methods
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
/*-******************************************
* bitStream encoding API (write forward)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
public enum BIT_DStream_status
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
/*-********************************************
* bitStream decoding API (read backward)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Runtime.CompilerServices;
using static ZstdSharp.UnsafeHelper;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
public static unsafe partial class Methods
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
/**
* COVER_best_t is used for two purposes:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
/**
* Struct used for the dictionary selection function.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
/**
*Number of epochs and size of each epoch.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
/**
* A segment is a range in the source as well as the score of the segment.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using static ZstdSharp.UnsafeHelper;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
public static unsafe partial class Methods
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
/*-***************************/
/* generic DTableDesc */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
public unsafe partial struct EStats_ress_t
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Runtime.CompilerServices;
using static ZstdSharp.UnsafeHelper;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
public static unsafe partial class Methods
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Runtime.CompilerServices;
using static ZstdSharp.UnsafeHelper;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
public static unsafe partial class Methods
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
/*-*************************************
* Acceleration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
/*-*************************************
* Context
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
/**
* Parameters for FASTCOVER_tryParameters().
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
/* *****************************************
* FSE symbol compression API
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
/* *****************************************
* FSE symbol decompression API
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
/* ====== Decompression ====== */
public partial struct FSE_DTableHeader
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
public partial struct FSE_decode_t
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
public enum FSE_repeat
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
/* *****************************************
* Implementation of inlined functions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using static ZstdSharp.UnsafeHelper;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
public static unsafe partial class Methods
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Runtime.CompilerServices;
using static ZstdSharp.UnsafeHelper;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
public static unsafe partial class Methods
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using static ZstdSharp.UnsafeHelper;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
public static unsafe partial class Methods
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Runtime.CompilerServices;
using static ZstdSharp.UnsafeHelper;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
public static unsafe partial class Methods
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
public enum HIST_checkInput_e
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
/* static allocation of HUF's Compression Table */
/* this is a private definition, just exposed for allocation and strict aliasing purpose. never EVER access its members directly */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
/*-***************************/
/* single-symbol decoding */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
/* *************************/
/* double-symbols decoding */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
public unsafe partial struct HUF_ReadDTableX1_Workspace
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
public partial struct HUF_buildCTable_wksp_tables
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
public unsafe partial struct HUF_compress_tables_t
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Runtime.InteropServices;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public unsafe delegate nuint HUF_decompress_usingDTable_t(void* dst, nuint dstSize, void* cSrc, nuint cSrcSize, uint* DTable);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace ZstdSharp
namespace ZstdSharp.Unsafe
{
public enum HUF_nbStreams_e
{
Expand Down
Loading

0 comments on commit 36353a7

Please sign in to comment.