From: Zooko O'Whielacronx Date: Wed, 31 Jan 2007 20:55:31 +0000 (-0700) Subject: pyfec: tighten internal C types X-Git-Tag: tahoe_v0.1.0-0-UNSTABLE~138 X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/css/%3C?a=commitdiff_plain;h=7b9630d59c32949c4016419ef8574621a10ed7ed;p=tahoe-lafs%2Ftahoe-lafs.git pyfec: tighten internal C types --- diff --git a/pyfec/fec/_fecmodule.c b/pyfec/fec/_fecmodule.c index d1c31748..1a69e00e 100644 --- a/pyfec/fec/_fecmodule.c +++ b/pyfec/fec/_fecmodule.c @@ -208,7 +208,7 @@ Encoder_encode(Encoder *self, PyObject *args) { } /* Allocate space for all of the check blocks. */ - unsigned check_block_index = 0; /* index into the check_blocks_produced and (parallel) pystrs_produced arrays */ + unsigned char check_block_index = 0; /* index into the check_blocks_produced and (parallel) pystrs_produced arrays */ for (i=0; i= self->kk) { c_desired_checkblocks_ids[check_block_index] = c_desired_blocks_nums[i]; diff --git a/pyfec/fec/fec.c b/pyfec/fec/fec.c index 24c0ba32..a848d0f3 100644 --- a/pyfec/fec/fec.c +++ b/pyfec/fec/fec.c @@ -434,14 +434,14 @@ _invert_mat(gf* src, unsigned k) { * p = coefficients of the matrix (p_i) * q = values of the polynomial (known) */ -void -_invert_vdm (gf* src, unsigned k) { - unsigned i, j, row, col; +int +_invert_vdm (gf * src, int k) { + int i, j, row, col; gf *b, *c, *p; gf t, xx; if (k == 1) /* degenerate case, matrix must be p^0 = 1 */ - return; + return 0; /* * c holds the coefficient of P(x) = Prod (x - p_i), i=0..k-1 * b holds the coefficient for the matrix inversion @@ -486,7 +486,7 @@ _invert_vdm (gf* src, unsigned k) { free (c); free (b); free (p); - return; + return 0; } static int fec_initialized = 0; @@ -565,7 +565,7 @@ fec_new(unsigned k, unsigned n) { void fec_encode(const fec_t* code, const gf*restrict const*restrict const src, gf*restrict const*restrict const fecs, const unsigned*restrict const block_nums, size_t num_block_nums, size_t sz) { - unsigned i, j; + unsigned char i, j; unsigned fecnum; gf* p; @@ -586,7 +586,7 @@ fec_encode(const fec_t* code, const gf*restrict const*restrict const src, gf*res */ void build_decode_matrix_into_space(const fec_t*restrict const code, const unsigned*const restrict index, const unsigned k, gf*restrict const matrix) { - unsigned i; + unsigned char i; gf* p; for (i=0, p=matrix; i < k; i++, p += k) { if (index[i] < k) { @@ -604,11 +604,11 @@ fec_decode(const fec_t* code, const gf*restrict const*restrict const inpkts, gf* gf m_dec[code->k * code->k]; build_decode_matrix_into_space(code, index, code->k, m_dec); - unsigned outix=0; - for (unsigned row=0; rowk; row++) { + unsigned char outix=0; + for (unsigned char row=0; rowk; row++) { if (index[row] >= code->k) { memset(outpkts[outix], 0, sz); - for (unsigned col=0; col < code->k; col++) + for (unsigned char col=0; col < code->k; col++) addmul(outpkts[outix], inpkts[col], m_dec[row * code->k + col], sz); outix++; }