Closed zlucode closed 5 years ago
example.c |__main()
unsigned char *output_file_data; size_t output_file_size; ///====This function allocates the out buffer with standard malloc ========= unsigned int out_status = lodepng_encode(&output_file_data, &output_file_size, raw_8bit_pixels, width, height, &state); if (out_status) { fprintf(stderr, "Can't encode image: %s\n", lodepng_error_text(out_status)); return EXIT_FAILURE; } ///but seems never free output_file_data const char *output_png_file_path = "quantized_example.png"; FILE *fp = fopen(output_png_file_path, "wb"); if (!fp) { fprintf(stderr, "Unable to write to %s\n", output_png_file_path); return EXIT_FAILURE; } fwrite(output_file_data, 1, output_file_size, fp);
Is it necessary to add free(output_file_data) in the end of main() function?
B.R. Lu
Yes, it's necessary to free it. It's just an example, not a complete implementation.
example.c |__main()
Is it necessary to add free(output_file_data) in the end of main() function?
B.R. Lu