优化指针释放

This commit is contained in:
猪小乐 2023-06-15 14:20:26 +08:00
parent 1583ffcb42
commit 0e9a905f85

View File

@ -291,6 +291,7 @@ int close_file_avis( avis_input_t *handle )
AVIStreamRelease(h->p_avi);
AVIFileExit();
free(h);
h = NULL;
return 0;
#else
fclose((FILE *)handle);
@ -424,10 +425,18 @@ void write_png(char *dir, int file_id, uint8_t *image, int w, int h, int graphic
/* Free memory */
png_destroy_write_struct(&png_ptr, &info_ptr);
free(row_pointers);
row_pointers = NULL;
if (palette != NULL)
{
free(palette);
palette = NULL;
}
if (trans != NULL)
{
free(trans);
trans = NULL;
}
/* Close file handle */
fclose(fh);
@ -1187,11 +1196,17 @@ int main (int argc, char *argv[])
assert(pal != NULL);
write_sup_wrapper(sw, (uint8_t *)out_buf, n_crop, crops, pal, start_frame + to, i + to, split_at, min_split, stricter, mark_forced);
if (!xml_output)
{
free(pal);
pal = NULL;
pal = NULL;
}
}
if (xml_output)
{
add_event_xml(events, split_at, min_split, start_frame + to, i + to, n_crop, crops, mark_forced);
free(pal);
pal = NULL;
}
end_frame = i;
have_line = 0;
}
@ -1252,8 +1267,10 @@ int main (int argc, char *argv[])
assert(pal != NULL);
write_sup_wrapper(sw, (uint8_t *)out_buf, n_crop, crops, pal, start_frame + to, i - 1 + to, split_at, min_split, stricter, mark_forced);
if (!xml_output)
{
free(pal);
pal = NULL;
pal = NULL;
}
}
if (xml_output)
{