Example #1
0
File: lz4.go Project: rhakt/lz4
// Decompress : Decompress
func Decompress(in, out []byte) (outSize int, err error) {
	outSize = int(C.LZ4_decompress_safe(p(in), p(out), clen(in), clen(out)))
	if outSize < 0 {
		err = fmt.Errorf("fail to decompress")
	}
	return
}
Example #2
0
func lz4Decompress(src []byte, dst []byte, maxSize uint32) (int, error) {
	n := C.LZ4_decompress_safe((*C.char)(unsafe.Pointer(&src[0])),
		(*C.char)(unsafe.Pointer(&dst[0])), C.int(len(src)), C.int(maxSize))
	if n < 0 {
		return 0, errors.New("lz4: data corruption")
	}
	return int(n), nil
}