]> git.rkrishnan.org Git - tahoe-lafs/zfec.git/commitdiff
pyfec: tighten internal C types
authorZooko O'Whielacronx zooko@zooko.com <zooko@zooko.com>
Wed, 31 Jan 2007 19:55:31 +0000 (01:25 +0530)
committerZooko O'Whielacronx zooko@zooko.com <zooko@zooko.com>
Wed, 31 Jan 2007 19:55:31 +0000 (01:25 +0530)
darcs-hash:48eb7f1dabf1a039b98037d687f086abf52710b2

pyfec/fec/_fecmodule.c
pyfec/fec/fec.c

index d1c31748479ed15876a195fa9612401a29fbcb4b..1a69e00eb554f19220e4c9aee47c0175adfbaf4a 100644 (file)
@@ -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<num_desired_blocks; i++) {
         if (c_desired_blocks_nums[i] >= self->kk) {
             c_desired_checkblocks_ids[check_block_index] = c_desired_blocks_nums[i];
index 24c0ba3287b07835f6ce557aa38739eb913328a5..a848d0f34e3e4b9f47feec5f9702068d101533db 100644 (file)
@@ -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; row<code->k; row++) {
+    unsigned char outix=0;
+    for (unsigned char row=0; row<code->k; 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++;
         }