X-Git-Url: https://git.llucax.com/z.facultad/75.06/jacu.git/blobdiff_plain/92acf059b083a5874172215f13c94c4071536b22..66f873a3de4adb65bbad6fb09cd57272216d332f:/src/mtf/mtf.c?ds=sidebyside diff --git a/src/mtf/mtf.c b/src/mtf/mtf.c index 6326b5e..5bf5b39 100644 --- a/src/mtf/mtf.c +++ b/src/mtf/mtf.c @@ -3,7 +3,7 @@ /****privadas*****/ int no_pertenece(char *z, char c, int len); -void pop_front(char *z, int pos); +void pop_front(char *z, unsigned int pos); int get_pos(char *z, int len, char c); /****fin privadas******/ @@ -16,42 +16,41 @@ void print_z(char *z, int len) fprintf(stderr, "\n"); } -char *jacu_mtf(char *datos, int len, char **_z, int *z_len) +unsigned char *jacu_mtf(unsigned char *datos, int len, unsigned char **_z, int *z_len) { - char *z; - char *pos; + unsigned char *z; + unsigned char *pos; int i, size; - pos = (char *)malloc(len*sizeof(char)); + pos = (unsigned char *)malloc(len*sizeof(unsigned char)); z = jacu_buscar_z(datos, len, &size); - (*_z) = jacu_buscar_z(datos, len, &size); - + *_z = (unsigned char*)malloc(size*sizeof(unsigned char)); + memcpy(*_z, z, size*sizeof(unsigned char)); for(i=0; i 255) printf("pos > = %u\n", pos); + if (pos < 0u) printf("pos < = %d\n", pos); aux = z[pos]; for(i=pos; i>0; i--) z[i]=z[i-1];