mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-12 18:11:35 -06:00
Update lz4, lz5 and zstd to latest stable series
- added some more error checking in zstdmt also
This commit is contained in:
@@ -154,11 +154,29 @@ ZSTDMT_CCtx *ZSTDMT_createCCtx(int threads, int level, int inputsize)
|
||||
|
||||
return ctx;
|
||||
|
||||
err_ctx:
|
||||
err_ctx:
|
||||
free(ctx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* mt_error - return mt lib specific error code
|
||||
*/
|
||||
static size_t mt_error(int rv)
|
||||
{
|
||||
switch (rv) {
|
||||
case -1:
|
||||
return ZSTDMT_ERROR(read_fail);
|
||||
case -2:
|
||||
return ZSTDMT_ERROR(canceled);
|
||||
case -3:
|
||||
return ZSTDMT_ERROR(memory_allocation);
|
||||
}
|
||||
|
||||
/* XXX, some catch all other errors */
|
||||
return ZSTDMT_ERROR(read_fail);
|
||||
}
|
||||
|
||||
/**
|
||||
* pt_write - queue for compressed output
|
||||
*/
|
||||
@@ -178,10 +196,8 @@ static size_t pt_write(ZSTDMT_CCtx * ctx, struct writelist *wl)
|
||||
b.buf = frame0;
|
||||
b.size = 9;
|
||||
rv = ctx->fn_write(ctx->arg_write, &b);
|
||||
if (rv == -1)
|
||||
return ZSTDMT_ERROR(write_fail);
|
||||
if (rv == -2)
|
||||
return ZSTDMT_ERROR(canceled);
|
||||
if (rv < 0)
|
||||
return mt_error(rv);
|
||||
if (b.size != 9)
|
||||
return ZSTDMT_ERROR(write_fail);
|
||||
ctx->outsize += 9;
|
||||
@@ -197,10 +213,8 @@ static size_t pt_write(ZSTDMT_CCtx * ctx, struct writelist *wl)
|
||||
wl = list_entry(entry, struct writelist, node);
|
||||
if (wl->frame == ctx->curframe) {
|
||||
rv = ctx->fn_write(ctx->arg_write, &wl->out);
|
||||
if (rv == -1)
|
||||
return ZSTDMT_ERROR(write_fail);
|
||||
if (rv == -2)
|
||||
return ZSTDMT_ERROR(canceled);
|
||||
if (rv < 0)
|
||||
return mt_error(rv);
|
||||
ctx->outsize += wl->out.size;
|
||||
ctx->curframe++;
|
||||
list_move(entry, &ctx->writelist_free);
|
||||
@@ -264,13 +278,9 @@ static void *pt_compress(void *arg)
|
||||
pthread_mutex_lock(&ctx->read_mutex);
|
||||
in.size = ctx->inputsize;
|
||||
rv = ctx->fn_read(ctx->arg_read, &in);
|
||||
if (rv == -1) {
|
||||
if (rv < 0) {
|
||||
pthread_mutex_unlock(&ctx->read_mutex);
|
||||
result = ZSTDMT_ERROR(read_fail);
|
||||
goto error;
|
||||
} else if (rv == -2) {
|
||||
pthread_mutex_unlock(&ctx->read_mutex);
|
||||
result = ZSTDMT_ERROR(canceled);
|
||||
result = mt_error(rv);
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -291,13 +301,15 @@ static void *pt_compress(void *arg)
|
||||
|
||||
/* compress whole frame */
|
||||
{
|
||||
unsigned char *outbuf = out->buf;
|
||||
result = ZSTD_compress(outbuf + 12, out->size - 12, in.buf, in.size, ctx->level);
|
||||
if (ZSTD_isError(result)) {
|
||||
zstdmt_errcode = result;
|
||||
result = ZSTDMT_ERROR(compression_library);
|
||||
goto error;
|
||||
}
|
||||
unsigned char *outbuf = out->buf;
|
||||
result =
|
||||
ZSTD_compress(outbuf + 12, out->size - 12, in.buf,
|
||||
in.size, ctx->level);
|
||||
if (ZSTD_isError(result)) {
|
||||
zstdmt_errcode = result;
|
||||
result = ZSTDMT_ERROR(compression_library);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
/* write skippable frame */
|
||||
|
||||
Reference in New Issue
Block a user