Frees resources allocated by various functions along the way. Only frees * data_out if !leave_data_out (if the bitmap loads successfully, you want the * data to remain until THEY free it). */
| 889 | * data to remain until THEY free it). |
| 890 | */ |
| 891 | static void FreeContext(read_context * p_ctx, int leave_data_out) |
| 892 | { |
| 893 | if(p_ctx->fp) |
| 894 | fclose(p_ctx->fp); |
| 895 | if(p_ctx->palette) |
| 896 | free(p_ctx->palette); |
| 897 | if(p_ctx->file_data) |
| 898 | free(p_ctx->file_data); |
| 899 | |
| 900 | if(!leave_data_out && p_ctx->data_out) |
| 901 | free(p_ctx->data_out); |
| 902 | } |
| 903 | |
| 904 | int bmpread(const char * bmp_file, unsigned int flags, bmpread_t * p_bmp_out) |
| 905 | { |