]> git.llucax.com Git - z.facultad/75.06/jacu.git/blobdiff - src/mtf/mtf.c
Subo BS (Merge con exito!)
[z.facultad/75.06/jacu.git] / src / mtf / mtf.c
index 9f394e31ae0d6749c7f4b2147a9713729f72c223..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);
-       *_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;
+       free(z);
        return pos;
 }
 
@@ -71,7 +72,6 @@ int no_pertenece(char *z, char c, int len)
 {
        int i;
        
-       /* XXX Z NO TIENE 255 POSICIONES XXX */
        for(i=0; i<len; i++)
                if (z[i] == c)
                        return 0;