/// <summary>Gets the maximum compressed length for given input length.</summary> /// <param name="inputLength">The input length.</param> /// <returns>Maximum compressed length.</returns> public static int GetMaximumCompressedLength(int inputLength) { if (IntPtr.Size == 4) { return(Snappy32.GetMaximumCompressedLength(inputLength)); } else { // checked - exception here is better than just random errors later return(checked ((int)Snappy64.GetMaximumCompressedLength(inputLength))); } }
/// <summary>Compresses the specified input.</summary> /// <param name="input">The input.</param> /// <param name="inputLength">Length of the input.</param> /// <param name="output">The output.</param> /// <param name="outputLength">Length of the output.</param> /// <returns>Status.</returns> public static unsafe SnappyStatus Compress( byte *input, int inputLength, byte *output, ref int outputLength) { if (IntPtr.Size == 4) { return(Snappy32.Compress(input, inputLength, output, ref outputLength)); } else { long l = outputLength; var result = Snappy64.Compress(input, inputLength, output, ref l); // checked - exception here is better than just random errors later outputLength = checked ((int)l); return(result); } }
/// <summary>Gets the uncompressed length.</summary> /// <param name="compressed">The compressed buffer.</param> /// <param name="compressedLength">Length of the compressed buffer.</param> /// <param name="uncompressedLength">Returns uncompressed length.</param> /// <returns>Status.</returns> public static unsafe SnappyStatus GetUncompressedLength( byte *compressed, int compressedLength, ref int uncompressedLength) { if (IntPtr.Size == 4) { return(Snappy32.GetUncompressedLength(compressed, compressedLength, ref uncompressedLength)); } else { long l = uncompressedLength; var result = Snappy64.GetUncompressedLength(compressed, compressedLength, ref l); // checked - exception here is better than just random errors later uncompressedLength = checked ((int)l); return(result); } }