int64_t lzbench_ucl_nrv2d_compress(char *inbuf, size_t insize, char *outbuf, size_t outsize, size_t level, size_t, char*) { ucl_uint complen; int res = ucl_nrv2d_99_compress((uint8_t*)inbuf, insize, (uint8_t*)outbuf, &complen, NULL, level, NULL, NULL); if (res != UCL_E_OK) return 0; return complen; }
int pack_section(const u8 * source, u8 ** dest, u32 source_size) { ucl_uint packed_size; u8 * packed; packed_size = source_size * 1.2 + 2048; packed = (u8 *) malloc(packed_size); if (ucl_nrv2d_99_compress(source, source_size, packed, &packed_size, NULL, 10, NULL, NULL) != UCL_E_OK) { printe("Error during ucl_nrv2b_99_compress.\n"); } packed = realloc(packed, packed_size); *dest = packed; return packed_size; }
int64_t lzbench_ucl_compress(char *inbuf, size_t insize, char *outbuf, size_t outsize, size_t algo, size_t level, size_t) { ucl_uint complen; int res; switch (algo) { default: case 1: res = ucl_nrv2b_99_compress((uint8_t*)inbuf, insize, (uint8_t*)outbuf, &complen, NULL, level, NULL, NULL); break; case 2: res = ucl_nrv2d_99_compress((uint8_t*)inbuf, insize, (uint8_t*)outbuf, &complen, NULL, level, NULL, NULL); break; case 3: res = ucl_nrv2e_99_compress((uint8_t*)inbuf, insize, (uint8_t*)outbuf, &complen, NULL, level, NULL, NULL); break; } if (res != UCL_E_OK) return 0; return complen; }
else { throwInternalError("unknown compression method"); return UPX_E_ERROR; } // optimize compression parms if (level <= 3 && cconf.max_offset == UCL_UINT_MAX) cconf.max_offset = 8*1024-1; else if (level == 4 && cconf.max_offset == UCL_UINT_MAX) cconf.max_offset = 32*1024-1; if M_IS_NRV2B(method) r = ucl_nrv2b_99_compress(src, src_len, dst, dst_len, &cb, level, &cconf, res); else if M_IS_NRV2D(method) r = ucl_nrv2d_99_compress(src, src_len, dst, dst_len, &cb, level, &cconf, res); else if M_IS_NRV2E(method) r = ucl_nrv2e_99_compress(src, src_len, dst, dst_len, &cb, level, &cconf, res); else { throwInternalError("unknown compression method"); return UPX_E_ERROR; } // make sure first_offset_found is set if (res[6] == 0) res[6] = 1; return convert_errno_from_ucl(r); }