This commit is contained in:
Isaac Shoebottom 2023-12-04 19:44:06 -04:00
parent 2769651fe1
commit 9f9d7a1925
2 changed files with 4 additions and 6 deletions

View File

@ -40,7 +40,7 @@ int main(int argc, char *argv[]) {
} }
printf("Chunk size is:%d\n", chunks[i]->length); printf("Chunk size is:%d\n", chunks[i]->length);
} }
write_png_chunks(path, chunks); // write_png_chunks(path, chunks);
destroy_chunks(chunks); destroy_chunks(chunks);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -123,10 +123,7 @@ png_chunk **get_png_chunks(char *buffer) {
int get_number_of_chunks(png_chunk **chunks) { int get_number_of_chunks(png_chunk **chunks) {
int i = 0; int i = 0;
while (true) { while (memcmp(chunks[i]->type, "IEND", 4) != 0) {
if (memcmp(chunks[i]->type, "IEND", 4) == 0) {
break;
}
i++; i++;
} }
return i; return i;
@ -141,7 +138,8 @@ void xor_data(png_chunk *chunk) {
void destroy_chunks(png_chunk **chunks) { void destroy_chunks(png_chunk **chunks) {
for (int i = 0; get_number_of_chunks(chunks); i++) { unsigned int size = get_number_of_chunks(chunks);
for (int i = 0; i < size; i++) {
free(chunks[i]->data); free(chunks[i]->data);
free(chunks[i]); free(chunks[i]);
} }