mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Remove valgrind errors
This commit is contained in:
parent
3e68f49f35
commit
bd9765bfd1
@ -102,7 +102,7 @@ int aztec_text_process(unsigned char source[], char binary_string[])
|
||||
}
|
||||
|
||||
i++;
|
||||
}while(i < maplength);
|
||||
}while(i < (maplength - 1));
|
||||
|
||||
/* look for blocks of characters which use the same table */
|
||||
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; }
|
||||
|
||||
/* 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]) {
|
||||
blockmap[0][i] = (blockmap[0][i] & blockmap[0][i + 1]);
|
||||
}
|
||||
@ -657,7 +657,7 @@ int aztec(struct zint_symbol *symbol, unsigned char source[])
|
||||
for(i = 0; i <= data_length; i++) {
|
||||
adjusted_string[i] = binary_string[i];
|
||||
}
|
||||
|
||||
|
||||
/* Data string can't have all '0's or all '1's in a block */
|
||||
i = 0;
|
||||
do{
|
||||
@ -675,7 +675,7 @@ int aztec(struct zint_symbol *symbol, unsigned char source[])
|
||||
insert(adjusted_string, i+(codeword_size - 1), '0');
|
||||
}
|
||||
i += codeword_size;
|
||||
} while (i < strlen(adjusted_string));
|
||||
} while ((i + codeword_size) < strlen(adjusted_string));
|
||||
adjusted_length = strlen(adjusted_string);
|
||||
|
||||
} 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');
|
||||
}
|
||||
i += codeword_size;
|
||||
} while (i < strlen(adjusted_string));
|
||||
} while ((i + codeword_size) < strlen(adjusted_string));
|
||||
adjusted_length = strlen(adjusted_string);
|
||||
|
||||
/* Check if the data actually fits into the selected symbol size */
|
||||
|
@ -131,10 +131,10 @@ int cc_a(struct zint_symbol *symbol, unsigned char source[], int cc_width)
|
||||
|
||||
bitlen = ustrlen(source);
|
||||
|
||||
for(i = bitlen; i < 197; i++) {
|
||||
for(i = bitlen; i < 208; i++) {
|
||||
source[i] = '0';
|
||||
}
|
||||
source[197] = '\0';
|
||||
source[208] = '\0';
|
||||
|
||||
for(segment = 0; segment < 13; segment++) {
|
||||
strpos = segment * 16;
|
||||
|
@ -62,13 +62,6 @@ void rs_init_gf(int poly)
|
||||
{
|
||||
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
|
||||
for (b = 1, m = 0; b <= poly; b <<= 1)
|
||||
m++;
|
||||
@ -102,8 +95,6 @@ void rs_init_code(int nsym, int index)
|
||||
{
|
||||
int i, k;
|
||||
|
||||
if (rspoly)
|
||||
free(rspoly);
|
||||
rspoly = (int *)malloc(sizeof(int) * (nsym + 1));
|
||||
|
||||
rlen = nsym;
|
||||
@ -143,6 +134,12 @@ void rs_encode(int len, unsigned char *data, unsigned char *res)
|
||||
else
|
||||
res[0] = 0;
|
||||
}
|
||||
|
||||
free(log);
|
||||
free(alog);
|
||||
free(rspoly);
|
||||
rspoly = NULL;
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
res[0] = 0;
|
||||
}
|
||||
|
||||
free(log);
|
||||
free(alog);
|
||||
free(rspoly);
|
||||
rspoly = NULL;
|
||||
}
|
||||
|
||||
|
@ -933,7 +933,7 @@ int general_rules(char field[], char type[])
|
||||
current = block[1][i];
|
||||
next = block[1][i + 1];
|
||||
|
||||
if(current == ISOIEC) {
|
||||
if((current == ISOIEC) && (i != (block_count - 1))) {
|
||||
if((next == ANY_ENC) && (block[0][i + 1] >= 4)) {
|
||||
block[1][i + 1] = NUMERIC;
|
||||
}
|
||||
@ -952,7 +952,7 @@ int general_rules(char field[], char type[])
|
||||
block[1][i] = ALPHA;
|
||||
}
|
||||
|
||||
if(current == ALPHA) {
|
||||
if((current == ALPHA) && (i != (block_count - 1))) {
|
||||
if((next == ANY_ENC) && (block[0][i + 1] >= 6)) {
|
||||
block[1][i + 1] = NUMERIC;
|
||||
}
|
||||
@ -1798,8 +1798,12 @@ int rss_binary_string(struct zint_symbol *symbol, unsigned char source[], char b
|
||||
}
|
||||
|
||||
/* Now add padding to binary string */
|
||||
if (general_field_type[strlen(general_field) - 1] == NUMERIC) {
|
||||
strcpy(padstring, "000000100001");
|
||||
if(strlen(general_field) != 0) {
|
||||
if (general_field_type[strlen(general_field) - 1] == NUMERIC) {
|
||||
strcpy(padstring, "000000100001");
|
||||
} else {
|
||||
strcpy(padstring, "001000010000");
|
||||
}
|
||||
} else {
|
||||
strcpy(padstring, "001000010000");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user