X-Git-Url: https://git.llucax.com/z.facultad/75.06/jacu.git/blobdiff_plain/de5da6745aa448b96eee01fbd9df0575629678b9..5cde90ce82c099520a3cfe2f0bc533b65216137a:/src/blocksorting/bs.c diff --git a/src/blocksorting/bs.c b/src/blocksorting/bs.c index 21e1ff6..9463b43 100644 --- a/src/blocksorting/bs.c +++ b/src/blocksorting/bs.c @@ -1,5 +1,6 @@ #include "bs.h" +#include /* Block Sorting Optimizado en memoria! */ @@ -72,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; @@ -93,6 +99,10 @@ 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 y el tamaño en el array */ + memcpy(out, &leido, sizeof(unsigned long int)); + memcpy(out+sizeof(unsigned long int), k, sizeof(unsigned long int)); + bs->len = l; }