]> 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 228fd8af1e4c6a87fe728d4fd7671d35145d7dd0..5bf5b39ce0f28cfab8eaafa829be4619508aee2a 100644 (file)
@@ -24,7 +24,7 @@ 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));
+       *_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]);
        memcpy(*_z, z, size*sizeof(unsigned char));
        for(i=0; i<len; i++){
                pos[i] = get_pos(z, size, datos[i]);
@@ -32,6 +32,7 @@ unsigned char *jacu_mtf(unsigned char *datos, int len, unsigned char **_z, int *
                        pop_front(z, pos[i]);
        }
        (*z_len) = size;
                        pop_front(z, pos[i]);
        }
        (*z_len) = size;
+       free(z);
        return pos;
 }
 
        return pos;
 }