示例#1
0
文件: lzo.go 项目: dgryski/go-lzo
func NewCompressor(level LzoAlgorithm) (*Compressor, error) {

	z := new(Compressor)
	z.level = level

	switch z.level {
	case Lzo1x_1:
		z.compress = lzo1x_1_compress
		z.wrkmem_len = int(C.lzo1x_1_mem_compress())
	case Lzo1x_999:
		z.compress = lzo1x_999_compress
		z.wrkmem_len = int(C.lzo1x_999_mem_compress())
	}

	return z, nil
}
示例#2
0
文件: lzo.go 项目: presbrey/lzo
func lzoCompressBest(src []byte, dst []byte, dst_size *int) C.int {
	wrkmem := make([]byte, int(C.lzo1x_999_mem_compress()))
	return C.lzo1x_999_compress((*C.uchar)(unsafe.Pointer(&src[0])), C.lzo_uint(len(src)),
		(*C.uchar)(unsafe.Pointer(&dst[0])), (*C.lzo_uint)(unsafe.Pointer(dst_size)),
		unsafe.Pointer(&wrkmem[0]))
}