X-Git-Url: https://git.llucax.com/z.facultad/75.06/jacu.git/blobdiff_plain/0aa658449bef68a63ecc6ba2960f93810a8a8341..0768f357f8e01a0baedfbb0ae1adf0e6fd4d4261:/src/blocksorting/bs.c diff --git a/src/blocksorting/bs.c b/src/blocksorting/bs.c index 7f8cb83..59a0de9 100644 --- a/src/blocksorting/bs.c +++ b/src/blocksorting/bs.c @@ -6,7 +6,7 @@ typedef struct _bs_decode_t_ { char c; - unsigned long int pos; + Uint32 pos; } t_BlockSortDecode; char es_menor(char *data, t_BlockSort *bs, int i, int j); @@ -31,7 +31,7 @@ int __compare(const void *d1, const void *d2) { char es_menor(char *data, t_BlockSort *bs, int i, int j) { - unsigned long int pi, pj, k; + Uint32 pi, pj, k; for(k=0; klen; k++) { pi = (i+k)%bs->len; @@ -61,9 +61,9 @@ void ordenar_array(char *data, t_BlockSort *bs) qsort(bs->array, bs->len, sizeof(t_BlockSortData), __compare); } -void print_(char *data, unsigned long int pos, unsigned long int len) +void print_(char *data, Uint32 pos, Uint32 len) { - unsigned long int i; + Uint32 i; 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; } -void bs_solve(char *in, char *out, t_BlockSort *bs, unsigned long int *k, unsigned int leido) +void bs_solve(char *in, char *out, t_BlockSort *bs, Uint32 *k, Uint32 leido) { unsigned int l; l = bs->len; @@ -94,15 +99,16 @@ 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, &leido, sizeof(Uint32)); + memcpy(out+sizeof(Uint32), k, sizeof(Uint32)); bs->len = l; } -void bs_restore(char *dst, char *c, unsigned long int k, unsigned long int len) +void bs_restore(char *dst, char *c, Uint32 k, Uint32 len) { - unsigned long int i, current; + Uint32 i, current; t_BlockSortDecode *in; in = malloc(sizeof(t_BlockSortDecode)*len); @@ -123,7 +129,7 @@ void bs_restore(char *dst, char *c, unsigned long int k, unsigned long int len) free(in); } -t_BlockSort *bs_create(unsigned long int len) +t_BlockSort *bs_create(Uint32 len) { t_BlockSort *tmp;