X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fcompress_serial.c;h=db41957ae17b8abdd862c70b3e02e58fa61c2e71;hb=944ca027b829261f33af8577fd8fe2afdc4d02b7;hp=0ae354834286b8e84db6987e7391df262f2df89e;hpb=883833a4b3dabec325edf1ca938000f91d587c00;p=wimlib diff --git a/src/compress_serial.c b/src/compress_serial.c index 0ae35483..db41957a 100644 --- a/src/compress_serial.c +++ b/src/compress_serial.c @@ -7,19 +7,18 @@ /* * Copyright (C) 2013 Eric Biggers * - * This file is part of wimlib, a library for working with WIM files. + * This file is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 3 of the License, or (at your option) any + * later version. * - * wimlib is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 3 of the License, or (at your option) any later - * version. + * This file is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. * - * wimlib is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with - * wimlib; if not, see http://www.gnu.org/licenses/. + * You should have received a copy of the GNU Lesser General Public License + * along with this file; if not, see http://www.gnu.org/licenses/. */ #ifdef HAVE_CONFIG_H @@ -38,8 +37,7 @@ struct serial_chunk_compressor { struct wimlib_compressor *compressor; u8 *udata; u8 *cdata; - unsigned ulen; - unsigned clen; + u32 ulen; }; static void @@ -58,7 +56,7 @@ serial_chunk_compressor_destroy(struct chunk_compressor *_ctx) static bool serial_chunk_compressor_submit_chunk(struct chunk_compressor *_ctx, - const void *chunk, size_t size) + const void *chunk, u32 size) { struct serial_chunk_compressor *ctx = (struct serial_chunk_compressor*)_ctx; @@ -75,21 +73,22 @@ serial_chunk_compressor_submit_chunk(struct chunk_compressor *_ctx, static bool serial_chunk_compressor_get_chunk(struct chunk_compressor *_ctx, - const void **cdata_ret, unsigned *csize_ret, - unsigned *usize_ret) + const void **cdata_ret, u32 *csize_ret, + u32 *usize_ret) { struct serial_chunk_compressor *ctx = (struct serial_chunk_compressor*)_ctx; + u32 clen; if (ctx->ulen == 0) return false; - ctx->clen = wimlib_compress(ctx->udata, ctx->ulen, - ctx->cdata, ctx->ulen - 1, - ctx->compressor); + clen = wimlib_compress(ctx->udata, ctx->ulen, + ctx->cdata, ctx->ulen - 1, + ctx->compressor); - if (ctx->clen) { + if (clen) { *cdata_ret = ctx->cdata; - *csize_ret = ctx->clen; + *csize_ret = clen; } else { *cdata_ret = ctx->udata; *csize_ret = ctx->ulen; @@ -107,6 +106,8 @@ new_serial_chunk_compressor(int out_ctype, u32 out_chunk_size, struct serial_chunk_compressor *ctx; int ret; + wimlib_assert(out_chunk_size > 0); + ctx = CALLOC(1, sizeof(*ctx)); if (ctx == NULL) return WIMLIB_ERR_NOMEM; @@ -118,9 +119,8 @@ new_serial_chunk_compressor(int out_ctype, u32 out_chunk_size, ctx->base.submit_chunk = serial_chunk_compressor_submit_chunk; ctx->base.get_chunk = serial_chunk_compressor_get_chunk; - ret = wimlib_create_compressor(out_ctype, out_chunk_size, - NULL, &ctx->compressor); + 0, &ctx->compressor); if (ret) goto err;