]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - fec.c
paraslash 0.7.3
[paraslash.git] / fec.c
diff --git a/fec.c b/fec.c
index e5c2a3b83e005c8596e6bcf951702bc3cb2cf5e1..932e0693e3786fc28b5a180428a9b296534a1fd5 100644 (file)
--- a/fec.c
+++ b/fec.c
@@ -97,7 +97,7 @@ static void init_mul_table(void)
 
 static unsigned char *alloc_matrix(int rows, int cols)
 {
-       return para_malloc(rows * cols);
+       return arr_alloc(rows, cols);
 }
 
 /*
@@ -182,11 +182,15 @@ static void generate_gf(void)
 static void addmul(unsigned char *dst1, const unsigned char *src1,
        unsigned char c, int sz)
 {
+       unsigned char *dst, *lim, *col;
+       const unsigned char *src = src1;
+
        if (c == 0)
                return;
-       unsigned char *dst = dst1, *lim = &dst[sz - UNROLL + 1],
-               *col = gf_mul_table[c];
-       const unsigned char *src = src1;
+
+       dst = dst1;
+       lim = &dst[sz - UNROLL + 1];
+       col = gf_mul_table[c];
 
        for (; dst < lim; dst += UNROLL, src += UNROLL) {
                dst[0] ^= col[src[0]];
@@ -241,9 +245,9 @@ static void matmul(unsigned char *a, unsigned char *b, unsigned char *c,
 static int invert_mat(unsigned char *src, int k)
 {
        int irow, icol, row, col, ix, error;
-       int *indxc = para_malloc(k * sizeof(int));
-       int *indxr = para_malloc(k * sizeof(int));
-       int *ipiv = para_malloc(k * sizeof(int)); /* elements used as pivots */
+       int *indxc = arr_alloc(k, sizeof(int));
+       int *indxr = arr_alloc(k, sizeof(int));
+       int *ipiv = arr_alloc(k, sizeof(int)); /* elements used as pivots */
        unsigned char c, *p, *id_row = alloc_matrix(1, k),
                *temp_row = alloc_matrix(1, k);
 
@@ -367,9 +371,9 @@ static void invert_vdm(unsigned char *src, int k)
         * c holds the coefficient of P(x) = Prod (x - p_i), i=0..k-1
         * b holds the coefficient for the matrix inversion
         */
-       c = para_malloc(k);
-       b = para_malloc(k);
-       p = para_malloc(k);
+       c = alloc(k);
+       b = alloc(k);
+       p = alloc(k);
 
        for (j = 1, i = 0; i < k; i++, j += k) {
                c[i] = 0;
@@ -462,7 +466,7 @@ int fec_new(int k, int n, struct fec_parms **result)
 
        if (k < 1 || k > GF_SIZE + 1 || n > GF_SIZE + 1 || k > n)
                return -E_FEC_PARMS;
-       parms = para_malloc(sizeof(struct fec_parms));
+       parms = alloc(sizeof(struct fec_parms));
        parms->k = k;
        parms->n = n;
        parms->enc_matrix = alloc_matrix(n, k);
@@ -603,10 +607,10 @@ int fec_decode(struct fec_parms *parms, unsigned char **data, int *idx,
        if (ret < 0)
                return ret;
        /* do the actual decoding */
-       slice = para_malloc(k * sizeof(unsigned char *));
+       slice = arr_alloc(k, sizeof(unsigned char *));
        for (row = 0; row < k; row++) {
                if (idx[row] >= k) {
-                       slice[row] = para_calloc(sz);
+                       slice[row] = zalloc(sz);
                        for (col = 0; col < k; col++)
                                addmul(slice[row], data[col],
                                        m_dec[row * k + col], sz);