equal
deleted
inserted
replaced
657 */ |
657 */ |
658 total = (knownTotal != -1) ? knownTotal : total; |
658 total = (knownTotal != -1) ? knownTotal : total; |
659 entries = zip->entries = calloc(total, sizeof(entries[0])); |
659 entries = zip->entries = calloc(total, sizeof(entries[0])); |
660 tablelen = zip->tablelen = ((total/2) | 1); // Odd -> fewer collisions |
660 tablelen = zip->tablelen = ((total/2) | 1); // Odd -> fewer collisions |
661 table = zip->table = malloc(tablelen * sizeof(table[0])); |
661 table = zip->table = malloc(tablelen * sizeof(table[0])); |
662 if (entries == NULL || table == NULL) goto Catch; |
662 /* According to ISO C it is perfectly legal for malloc to return zero |
|
663 * if called with a zero argument. We check this for 'entries' but not |
|
664 * for 'table' because 'tablelen' can't be zero (see computation above). */ |
|
665 if ((entries == NULL && total != 0) || table == NULL) goto Catch; |
663 for (j = 0; j < tablelen; j++) |
666 for (j = 0; j < tablelen; j++) |
664 table[j] = ZIP_ENDCHAIN; |
667 table[j] = ZIP_ENDCHAIN; |
665 |
668 |
666 /* Iterate through the entries in the central directory */ |
669 /* Iterate through the entries in the central directory */ |
667 for (i = 0, cp = cenbuf; cp <= cenend - CENHDR; i++, cp += CENSIZE(cp)) { |
670 for (i = 0, cp = cenbuf; cp <= cenend - CENHDR; i++, cp += CENSIZE(cp)) { |