/// <summary>Decompresses data from given buffer.</summary>
        /// <param name="source">Input buffer.</param>
        /// <param name="sourceLength">Input buffer length.</param>
        /// <param name="target">Output buffer.</param>
        /// <param name="targetLength">Output buffer length.</param>
        /// <returns>Number of bytes written, or negative value if output buffer is too small.</returns>
        public static unsafe int Decode(
            byte *source, int sourceLength,
            byte *target, int targetLength)
        {
            if (sourceLength <= 0)
            {
                return(0);
            }

            var decoded = LZ4_xx.LZ4_decompress_safe(source, target, sourceLength, targetLength);

            return(decoded <= 0 ? -1 : decoded);
        }
Beispiel #2
0
 public static int MaximumOutputSize(int length) => LZ4_xx.LZ4_compressBound(length);