Remove valgrind errors

This commit is contained in:
hooper114 2008-10-06 16:27:48 +00:00
parent 3e68f49f35
commit bd9765bfd1
4 changed files with 26 additions and 20 deletions

View File

@ -102,7 +102,7 @@ int aztec_text_process(unsigned char source[], char binary_string[])
} }
i++; i++;
}while(i < maplength); }while(i < (maplength - 1));
/* look for blocks of characters which use the same table */ /* look for blocks of characters which use the same table */
blocks = 0; blocks = 0;
@ -136,7 +136,7 @@ int aztec_text_process(unsigned char source[], char binary_string[])
if(blockmap[0][blocks - 1] & 8) { blockmap[0][blocks - 1] = 8; } if(blockmap[0][blocks - 1] & 8) { blockmap[0][blocks - 1] = 8; }
/* look for adjacent blocks which can use the same table (right to left search) */ /* look for adjacent blocks which can use the same table (right to left search) */
for(i = blocks; i > 0; i--) { for(i = blocks - 1; i > 0; i--) {
if(blockmap[0][i] & blockmap[0][i + 1]) { if(blockmap[0][i] & blockmap[0][i + 1]) {
blockmap[0][i] = (blockmap[0][i] & blockmap[0][i + 1]); blockmap[0][i] = (blockmap[0][i] & blockmap[0][i + 1]);
} }
@ -675,7 +675,7 @@ int aztec(struct zint_symbol *symbol, unsigned char source[])
insert(adjusted_string, i+(codeword_size - 1), '0'); insert(adjusted_string, i+(codeword_size - 1), '0');
} }
i += codeword_size; i += codeword_size;
} while (i < strlen(adjusted_string)); } while ((i + codeword_size) < strlen(adjusted_string));
adjusted_length = strlen(adjusted_string); adjusted_length = strlen(adjusted_string);
} while(adjusted_length > data_maxsize); } while(adjusted_length > data_maxsize);
@ -725,7 +725,7 @@ int aztec(struct zint_symbol *symbol, unsigned char source[])
insert(adjusted_string, i+(codeword_size - 1), '0'); insert(adjusted_string, i+(codeword_size - 1), '0');
} }
i += codeword_size; i += codeword_size;
} while (i < strlen(adjusted_string)); } while ((i + codeword_size) < strlen(adjusted_string));
adjusted_length = strlen(adjusted_string); adjusted_length = strlen(adjusted_string);
/* Check if the data actually fits into the selected symbol size */ /* Check if the data actually fits into the selected symbol size */

View File

@ -131,10 +131,10 @@ int cc_a(struct zint_symbol *symbol, unsigned char source[], int cc_width)
bitlen = ustrlen(source); bitlen = ustrlen(source);
for(i = bitlen; i < 197; i++) { for(i = bitlen; i < 208; i++) {
source[i] = '0'; source[i] = '0';
} }
source[197] = '\0'; source[208] = '\0';
for(segment = 0; segment < 13; segment++) { for(segment = 0; segment < 13; segment++) {
strpos = segment * 16; strpos = segment * 16;

View File

@ -62,13 +62,6 @@ void rs_init_gf(int poly)
{ {
int m, b, p, v; int m, b, p, v;
// Return storage from previous setup
if (log) {
free(log);
free(alog);
free(rspoly);
rspoly = NULL;
}
// Find the top bit, and hence the symbol size // Find the top bit, and hence the symbol size
for (b = 1, m = 0; b <= poly; b <<= 1) for (b = 1, m = 0; b <= poly; b <<= 1)
m++; m++;
@ -102,8 +95,6 @@ void rs_init_code(int nsym, int index)
{ {
int i, k; int i, k;
if (rspoly)
free(rspoly);
rspoly = (int *)malloc(sizeof(int) * (nsym + 1)); rspoly = (int *)malloc(sizeof(int) * (nsym + 1));
rlen = nsym; rlen = nsym;
@ -143,6 +134,12 @@ void rs_encode(int len, unsigned char *data, unsigned char *res)
else else
res[0] = 0; res[0] = 0;
} }
free(log);
free(alog);
free(rspoly);
rspoly = NULL;
} }
void rs_encode_long(int len, unsigned int *data, unsigned int *res) void rs_encode_long(int len, unsigned int *data, unsigned int *res)
@ -166,5 +163,10 @@ void rs_encode_long(int len, unsigned int *data, unsigned int *res)
else else
res[0] = 0; res[0] = 0;
} }
free(log);
free(alog);
free(rspoly);
rspoly = NULL;
} }

View File

@ -933,7 +933,7 @@ int general_rules(char field[], char type[])
current = block[1][i]; current = block[1][i];
next = block[1][i + 1]; next = block[1][i + 1];
if(current == ISOIEC) { if((current == ISOIEC) && (i != (block_count - 1))) {
if((next == ANY_ENC) && (block[0][i + 1] >= 4)) { if((next == ANY_ENC) && (block[0][i + 1] >= 4)) {
block[1][i + 1] = NUMERIC; block[1][i + 1] = NUMERIC;
} }
@ -952,7 +952,7 @@ int general_rules(char field[], char type[])
block[1][i] = ALPHA; block[1][i] = ALPHA;
} }
if(current == ALPHA) { if((current == ALPHA) && (i != (block_count - 1))) {
if((next == ANY_ENC) && (block[0][i + 1] >= 6)) { if((next == ANY_ENC) && (block[0][i + 1] >= 6)) {
block[1][i + 1] = NUMERIC; block[1][i + 1] = NUMERIC;
} }
@ -1798,11 +1798,15 @@ int rss_binary_string(struct zint_symbol *symbol, unsigned char source[], char b
} }
/* Now add padding to binary string */ /* Now add padding to binary string */
if(strlen(general_field) != 0) {
if (general_field_type[strlen(general_field) - 1] == NUMERIC) { if (general_field_type[strlen(general_field) - 1] == NUMERIC) {
strcpy(padstring, "000000100001"); strcpy(padstring, "000000100001");
} else { } else {
strcpy(padstring, "001000010000"); strcpy(padstring, "001000010000");
} }
} else {
strcpy(padstring, "001000010000");
}
padstring[remainder] = '\0'; padstring[remainder] = '\0';
concat(binary_string, padstring); concat(binary_string, padstring);