From fef03d51453b511c6355d53f1c4f5d06f1e8519e Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Sun, 27 Jun 2004 02:38:40 +0000 Subject: [PATCH 1/1] Fixed leak en MTF --- src/blocksorting/bs.c | 41 +++++++++++++++++++++++++++++++++++++++-- src/mtf/mtf.c | 1 + 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/blocksorting/bs.c b/src/blocksorting/bs.c index 93b7bb5..a1e14a2 100644 --- a/src/blocksorting/bs.c +++ b/src/blocksorting/bs.c @@ -1,6 +1,7 @@ #include "bs.h" #include +#include /* Block Sorting Optimizado en memoria! */ @@ -140,12 +141,48 @@ void bs_destroy(t_BlockSort *bs) free(bs); } + +void bs_EOL(char *data, Uint32 pagesize, Uint32 *j) +{ + /* Trato de agregar 4 espacios antes y 4 despues de un \n */ + int i = (*j); + + /* Verifico poder hacerlo */ + if ((i+9) >= pagesize) return; /* No pude! */ + + data[i++] = ' '; + data[i++] = ' '; + data[i++] = ' '; + data[i++] = ' '; + data[i++] = ' '; + data[i++] = ' '; + data[i++] = ' '; + data[i++] = ' '; + data[i++] = ' '; + + (*j) += 9; +} + int bs_readblock(FILE *fp, char *data, Uint32 pagesize) { Uint32 i=0; - + char c; while ((!feof(fp)) && (i < pagesize)) { - data[i++] = fgetc(fp); + c = fgetc(fp); +/* if (c != '\n')*/ + if (c == '\0') { + /* Debo encodear el \0 para que no complique */ + data[i++] = 0x00; + data[i++] = 0xFF; + } + if (isupper(c)) { + data[i++] = '\0'; + data[i++] = tolower(c); + } else { + data[i++] = c; + } +/* else + bs_EOL(data, pagesize, &i);*/ } /* Saco un EOF que lee de mas */ diff --git a/src/mtf/mtf.c b/src/mtf/mtf.c index b59f128..5bf5b39 100644 --- a/src/mtf/mtf.c +++ b/src/mtf/mtf.c @@ -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; + free(z); return pos; } -- 2.43.0