//go:build windows package yu_deflate // Zlib // // @Description: Zlib 格式压缩数据 // @param buf 欲压缩的数据 // @return []byte 压缩后的数据 func Zlib(buf []byte) []byte { if len(buf) == 0 { return nil } j_comp := m_pool_comp.Get().(*uintptr) defer m_pool_comp.Put(j_comp) var j_buf []byte if len(buf) < 64 { j_buf = make([]byte, 64) } else { j_buf = make([]byte, len(buf)) } var j_i int _compress: j_n, _, _ := libdeflate_zlib_compress.Call(*j_comp, buf, len(buf), j_buf, len(j_buf)) if j_i++; j_n == 0 && j_i < 3 { j_buf = make([]byte, len(buf)*j_i) goto _compress } return j_buf[:j_n] } // Deflate // // @Description: Deflate 格式压缩数据 // @param buf 欲压缩的数据 // @return []byte 压缩后的数据 func Deflate(buf []byte) []byte { if len(buf) == 0 { return nil } j_comp := m_pool_comp.Get().(*uintptr) defer m_pool_comp.Put(j_comp) var j_buf []byte if len(buf) < 64 { j_buf = make([]byte, 64) } else { j_buf = make([]byte, len(buf)) } var j_i int _compress: j_n, _, _ := libdeflate_deflate_compress.Call(*j_comp, buf, len(buf), j_buf, len(j_buf)) if j_i++; j_n == 0 && j_i < 3 { j_buf = make([]byte, len(buf)*j_i) goto _compress } return j_buf[:j_n] } // Gzip // // @Description: Gzip 格式压缩数据 // @param buf 欲压缩的数据 // @return []byte 压缩后的数据 func Gzip(buf []byte) []byte { if len(buf) == 0 { return nil } j_comp := m_pool_comp.Get().(*uintptr) defer m_pool_comp.Put(j_comp) var j_buf []byte if len(buf) < 64 { j_buf = make([]byte, 64) } else { j_buf = make([]byte, len(buf)) } var j_i int _compress: j_n, _, _ := libdeflate_gzip_compress.Call(*j_comp, buf, len(buf), j_buf, len(j_buf)) if j_i++; j_n == 0 && j_i < 3 { j_buf = make([]byte, len(buf)*j_i) goto _compress } return j_buf[:j_n] }