]> git.llucax.com Git - z.facultad/75.06/jacu.git/blobdiff - src/mtf/mtf.c
Hago que se genere el symlink de jacu a grupo11 en el make all :)
[z.facultad/75.06/jacu.git] / src / mtf / mtf.c
index 460b790d5a7c6cffe90b56c126657ddb178d2993..5bf5b39ce0f28cfab8eaafa829be4619508aee2a 100644 (file)
@@ -24,14 +24,15 @@ unsigned char *jacu_mtf(unsigned char *datos, int len, unsigned char **_z, int *
        
        pos = (unsigned char *)malloc(len*sizeof(unsigned char));
        z = jacu_buscar_z(datos, len, &size);
        
        pos = (unsigned char *)malloc(len*sizeof(unsigned char));
        z = jacu_buscar_z(datos, len, &size);
-       *_z = (unsigned char*)malloc(len*sizeof(unsigned char));
-       memcpy(*_z, z, len*sizeof(unsigned char));
+       *_z = (unsigned char*)malloc(size*sizeof(unsigned char));
+       memcpy(*_z, z, size*sizeof(unsigned char));
        for(i=0; i<len; i++){
                pos[i] = get_pos(z, size, datos[i]);
                if (pos[i] != 0) 
                        pop_front(z, pos[i]);
        }
        (*z_len) = size;
        for(i=0; i<len; i++){
                pos[i] = get_pos(z, size, datos[i]);
                if (pos[i] != 0) 
                        pop_front(z, pos[i]);
        }
        (*z_len) = size;
+       free(z);
        return pos;
 }
 
        return pos;
 }