Esempio n. 1
0
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
}
Esempio n. 2
0
File: lzo.go Progetto: presbrey/lzo
func lzoCompressSpeed(src []byte, dst []byte, dst_size *int) C.int {
	wrkmem := make([]byte, int(C.lzo1x_1_mem_compress()))
	return C.lzo1x_1_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]))
}