Esempio n. 1
0
 /// <summary>
 /// Tries to decompress the data.
 /// </summary>
 /// <param name="src">The data to decompress.</param>
 /// <param name="srcLength">The length of <see cref="src"/>.</param>
 /// <param name="dst">The array where the decompressed data gets stored.</param>
 /// <param name="dstLength">The length of the decompressed data.</param>
 /// <returns>Returns the result indicating wether the decompression was successful.</returns>
 /// <remarks>This method can be used from multiple threads.</remarks>
 public static LzoResult TryDecompress(
     ReadOnlySpan <byte> src,
     int srcLength,
     Span <byte> dst,
     out int dstLength
     )
 {
     return(LzoNative.DecompressSafe(src, srcLength, dst, out dstLength));
 }
Esempio n. 2
0
 /// <summary>
 /// Tries to compress the data with the specified <see cref="CompressionMode"/>.
 /// </summary>
 /// <param name="mode">The compression mode.</param>
 /// <param name="src">The data to compress.</param>
 /// <param name="srcLength">The length of <see cref="src"/>.</param>
 /// <param name="dst">The array where the compressed data gets stored.
 ///  Make sure the array is big enough. The official lzo example suggests <code>srcLength + srcLength / 16 + 64 + 3</code>.
 /// </param>
 /// <param name="dstLength">The length of the compressed data.</param>
 /// <param name="workMemory">The internal work memory for lzo.
 ///  The array should be at least the size of <see cref="Lzo.WorkMemorySize"/>.
 /// </param>
 /// <returns>Returns the result indicating wether the compression was successful.</returns>
 /// <remarks>This method can be used from multiple threads <b>as long as each concurrent operation has its own</b> <see cref="workMemory"/>.</remarks>
 public static LzoResult TryCompress(
     CompressionMode mode,
     ReadOnlySpan <byte> src,
     int srcLength,
     Span <byte> dst,
     out int dstLength,
     byte[] workMemory
     )
 {
     return(LzoNative.Compress(mode, src, srcLength, dst, out dstLength, workMemory));
 }