X-Git-Url: https://git.llucax.com/z.facultad/75.06/jacu.git/blobdiff_plain/0aa658449bef68a63ecc6ba2960f93810a8a8341..9e5f9df91ca96fb4cf179841cea17c9b4fb0f99c:/src/blocksorting/bs.c diff --git a/src/blocksorting/bs.c b/src/blocksorting/bs.c index 7f8cb83..64ea8ab 100644 --- a/src/blocksorting/bs.c +++ b/src/blocksorting/bs.c @@ -73,10 +73,15 @@ void print_(char *data, unsigned long int pos, unsigned long int len) int generar_salida(char *data, t_BlockSort *bs, char *salida) { unsigned long int i, k; + char *out; + + /* Dejo lugar para guardar el k y el tamaño de este bloque */ + out = salida + sizeof(unsigned long int)*2; + k=-1; for(i=0; ilen; i++) { /* print_(data, bs->array[i].pos_inicial, bs->len); */ - salida[i] = data[bs->array[i].pos_final]; + out[i] = data[bs->array[i].pos_final]; if (bs->array[i].ord == 1) k = i; } return k; @@ -94,8 +99,9 @@ void bs_solve(char *in, char *out, t_BlockSort *bs, unsigned long int *k, unsign ordenar_array(in, bs); (*k) = generar_salida(in, bs, out); - /* Guardo el k en el array */ - memcpy(out+leido, k, sizeof(unsigned long int)); + /* Guardo el k y el tamaño en el array */ + memcpy(out, k, sizeof(unsigned long int)); + memcpy(out+sizeof(unsigned long int), &leido, sizeof(unsigned long int)); bs->len = l; }