From 1882c39affc3b224871790bfe06ac71f293e5f2b Mon Sep 17 00:00:00 2001 From: "josh.macdonald" Date: Sun, 7 Nov 2010 16:48:21 +0000 Subject: Whitespace cleanups, comments --- xdelta3/xdelta3-blkcache.h | 6 +++--- xdelta3/xdelta3-test.h | 16 ++++++++-------- xdelta3/xdelta3.c | 24 ++++++++++++------------ xdelta3/xdelta3.h | 21 ++++++++++++--------- 4 files changed, 35 insertions(+), 32 deletions(-) (limited to 'xdelta3') diff --git a/xdelta3/xdelta3-blkcache.h b/xdelta3/xdelta3-blkcache.h index a570665..cf5fb7f 100644 --- a/xdelta3/xdelta3-blkcache.h +++ b/xdelta3/xdelta3-blkcache.h @@ -113,10 +113,10 @@ main_set_source (xd3_stream *stream, xd3_cmd cmd, else { /* Either a regular file (possibly compressed) or a FIFO - * (possibly compressed). */ + * (possibly compressed). */ if ((ret = main_file_open (sfile, sfile->filename, XO_READ))) { - return ret; + return ret; } /* If the file is regular we know it's size. If the file turns @@ -135,7 +135,7 @@ main_set_source (xd3_stream *stream, xd3_cmd cmd, * (lru_size==1) source block. Otherwise, we know that at least * option_srcwinsz bytes are available. Split the source window * into buffers. */ - if ((lru = (main_blklru*) main_malloc (MAX_LRU_SIZE * + if ((lru = (main_blklru*) main_malloc (MAX_LRU_SIZE * sizeof (main_blklru))) == NULL) { ret = ENOMEM; diff --git a/xdelta3/xdelta3-test.h b/xdelta3/xdelta3-test.h index 68499b1..f74e767 100644 --- a/xdelta3/xdelta3-test.h +++ b/xdelta3/xdelta3-test.h @@ -282,14 +282,14 @@ test_make_inputs (xd3_stream *stream, xoff_t *ss_out, xoff_t *ts_out) for (i = 0; i < ts; ) { usize_t left = ts - i; - usize_t next = mt_exp_rand ((uint32_t) TEST_ADD_MEAN, + usize_t next = mt_exp_rand ((uint32_t) TEST_ADD_MEAN, (uint32_t) TEST_ADD_MAX); usize_t add_left = sadd_max - sadd; double add_prob = (left == 0) ? 0 : (add_left / (double) left); int do_copy; next = min (left, next); - do_copy = (next > add_left || + do_copy = (next > add_left || (mt_random (&static_mtrand) / \ (double)USIZE_T_MAX) >= add_prob); @@ -305,8 +305,8 @@ test_make_inputs (xd3_stream *stream, xoff_t *ss_out, xoff_t *ts_out) if (do_copy) { /* Copy */ - size_t offset = mt_random (&static_mtrand) % ((ss_out == NULL) ? - i : + size_t offset = mt_random (&static_mtrand) % ((ss_out == NULL) ? + i : (ss - next)); /* DP(RINT "[%u] copy %u at %u ", i, next, offset); */ @@ -838,7 +838,7 @@ test_compress_text (xd3_stream *stream, (*encoded_size) = 0; - xd3_set_appheader (stream, test_apphead, + xd3_set_appheader (stream, test_apphead, (usize_t) strlen ((char*) test_apphead)); if ((ret = xd3_encode_stream (stream, test_text, sizeof (test_text), @@ -2371,9 +2371,9 @@ test_identical_behavior (xd3_stream *stream, int ignore) xd3_config config; memset(&source, 0, sizeof(source)); - for (i = 0; i < IDB_TGTSZ; i += 1) - { - buf[i] = (uint8_t) mt_random (&static_mtrand); + for (i = 0; i < IDB_TGTSZ; i += 1) + { + buf[i] = (uint8_t) mt_random (&static_mtrand); } stream->winsize = IDB_WINSZ; diff --git a/xdelta3/xdelta3.c b/xdelta3/xdelta3.c index 23877b1..1bc7fe5 100644 --- a/xdelta3/xdelta3.c +++ b/xdelta3/xdelta3.c @@ -1263,14 +1263,14 @@ int xd3_compute_code_table_encoding (xd3_stream *in_stream, * about 20 bytes. */ uint8_t dflt_string[CODE_TABLE_STRING_SIZE]; uint8_t code_string[CODE_TABLE_STRING_SIZE]; - + xd3_compute_code_table_string (xd3_rfc3284_code_table (), dflt_string); xd3_compute_code_table_string (code_table, code_string); return xd3_encode_memory (code_string, CODE_TABLE_STRING_SIZE, dflt_string, CODE_TABLE_STRING_SIZE, comp_string, comp_string_size, - CODE_TABLE_VCDIFF_SIZE, + CODE_TABLE_VCDIFF_SIZE, /* flags */ 0); } @@ -1362,8 +1362,8 @@ xd3_apply_table_string (xd3_stream *stream, const uint8_t *code_string) xd3_dinst *code_table; if ((code_table = stream->code_table_alloc = - (xd3_dinst*) xd3_alloc (stream, - (usize_t) sizeof (xd3_dinst), + (xd3_dinst*) xd3_alloc (stream, + (usize_t) sizeof (xd3_dinst), 256)) == NULL) { return ENOMEM; @@ -1873,12 +1873,12 @@ xd3_alloc_cache (xd3_stream *stream) if (((stream->acache.s_near > 0) && (stream->acache.near_array = (usize_t*) - xd3_alloc (stream, stream->acache.s_near, + xd3_alloc (stream, stream->acache.s_near, (usize_t) sizeof (usize_t))) == NULL) || ((stream->acache.s_same > 0) && (stream->acache.same_array = (usize_t*) - xd3_alloc (stream, stream->acache.s_same * 256, + xd3_alloc (stream, stream->acache.s_same * 256, (usize_t) sizeof (usize_t))) == NULL)) { @@ -2536,7 +2536,7 @@ xd3_getblk (xd3_stream *stream, xoff_t blkno) ret = stream->getblk (stream, source, blkno); if (ret != 0) { - IF_DEBUG1 (DP(RINT "[getblk] app error blkno %"Q"u: %s\n", + IF_DEBUG1 (DP(RINT "[getblk] app error blkno %"Q"u: %s\n", blkno, xd3_strerror (ret))); return ret; } @@ -2623,7 +2623,7 @@ xd3_set_source (xd3_stream *stream, } int -xd3_set_source_and_size (xd3_stream *stream, +xd3_set_source_and_size (xd3_stream *stream, xd3_source *user_source, xoff_t source_size) { int ret = xd3_set_source (stream, user_source); @@ -2799,7 +2799,7 @@ xd3_iopt_finish_encoding (xd3_stream *stream, xd3_rinst *inst) else { stream->srcwin_decided_early = (!stream->src->eof_known || - (stream->srcwin_cksum_pos < + (stream->srcwin_cksum_pos < xd3_source_eof (stream->src))); } @@ -2807,7 +2807,7 @@ xd3_iopt_finish_encoding (xd3_stream *stream, xd3_rinst *inst) if (inst->xtra) { XD3_ASSERT (inst->addr >= src->srcbase); - XD3_ASSERT (inst->addr + inst->size <= + XD3_ASSERT (inst->addr + inst->size <= src->srcbase + src->srclen); addr = (usize_t)(inst->addr - src->srcbase); stream->n_scpy += 1; @@ -2815,7 +2815,7 @@ xd3_iopt_finish_encoding (xd3_stream *stream, xd3_rinst *inst) } else { - /* with source window: target copy address is offset + /* with source window: target copy address is offset * by taroff. */ addr = stream->taroff + (usize_t) inst->addr; stream->n_tcpy += 1; @@ -3810,7 +3810,7 @@ xd3_encode_input (xd3_stream *stream) case ENC_SEARCH: IF_DEBUG2 (DP(RINT "[SEARCH] match_state %d avail_in %u %s\n", - stream->match_state, stream->avail_in, + stream->match_state, stream->avail_in, stream->src ? "source" : "no source")); /* Reentrant matching. */ diff --git a/xdelta3/xdelta3.h b/xdelta3/xdelta3.h index c831ac1..5dafd8d 100644 --- a/xdelta3/xdelta3.h +++ b/xdelta3/xdelta3.h @@ -1044,13 +1044,18 @@ int xd3_decode_memory (const uint8_t *input, usize_t avail_output, int flags); -/* This function encodes an in-memory input. The output array must be - * large enough to hold the output or else ENOSPC is returned. The - * source (if any) should be set using xd3_set_source() with a - * single-block xd3_source. This calls the underlying non-blocking - * interface, xd3_encode_input(), handling the necessary input/output - * states. This method be considered a reference for any application - * using xd3_encode_input() directly. +/* This function encodes an in-memory input using a pre-configured + * xd3_stream. This allows the caller to set a variety of options + * which are not available in the xd3_encode/decode_memory() + * functions. + * + * The output array must be large enough to hold the output or else + * ENOSPC is returned. The source (if any) should be set using + * xd3_set_source_and_size() with a single-block xd3_source. This + * calls the underlying non-blocking interfaces, + * xd3_encode/decode_input(), handling the necessary input/output + * states. This method may be considered a reference for any + * application using xd3_encode_input() directly. * * xd3_stream stream; * xd3_config config; @@ -1079,8 +1084,6 @@ int xd3_decode_memory (const uint8_t *input, * xd3_config_stream(&stream, &config); * xd3_encode_stream(&stream, ...); * xd3_free_stream(&stream); - * - * DO NOT USE except for testing. These methods are allocate bad buffer sizes. */ int xd3_encode_stream (xd3_stream *stream, const uint8_t *input, -- cgit v1.2.3