zstd_compress_bound returns the worst case scenario so that the buffer will be guaranteed to be large enough. I will look into reallocating the buffer since the worst case could very well be larger than the original size. Thanks,
Jon On Fri, Jun 3, 2022 at 4:59 PM Georgia Garcia <[email protected]> wrote: > On Thu, 2022-05-12 at 12:35 -0500, Jon Tourville wrote: > > + out_len = zstd_compress_cctx(ctx, out, out_len, src, slen, > ¶ms); > > + if (zstd_is_error(out_len)) { > > + ret = -EINVAL; > > + goto cleanup; > > } > > > > - *dst = dstbuf; > > - *dlen = strm.total_out; > > + *dst = out; > > + *dlen = out_len; > > Hi Jon, > > Should the dst/out buffer be realloced to match the out_len returned by > zstd_compress_cctx? Or is the estimation made by zstd_compress_bound > accurate? > > Regards, > Georgia > >
