+ /* after compression operation then execute decompression operation\r
+ to get decompression required memory size. */\r
+ if (decompress == 0) {\r
+ fin = OpenInputFile(output_path);\r
+ fout = tmpfile ();\r
+ msize = 0;\r
+ if (fseek(fin, 16, SEEK_SET) != 0) {\r
+ fclose(fin);\r
+ return -1;\r
+ }\r
+ is_ok = Decompress(fin, fout, dictionary_path, (void *)&msize);\r
+ if (!is_ok) {\r
+ exit(1);\r
+ }\r
+ if (fclose(fin) != 0) {\r
+ perror("fclose");\r
+ exit(1);\r
+ }\r
+ if (fclose(fout) != 0) {\r
+ perror("fclose");\r
+ exit(1);\r
+ }\r
+ fout = fopen(output_path, "rb+"); /* open output_path file and add in head info */\r
+ /* seek to the offset of decompression required memory size */\r
+ if (fseek(fout, 8, SEEK_SET) != 0) {\r
+ fclose(fout);\r
+ return -1;\r
+ }\r
+ msize += gmem * GAP_MEM_BLOCK; /* there is a memory gap between IA32 and X64 environment*/\r
+ fwrite(&msize, 1, sizeof(int64_t), fout); /* update final decompression required memory size */\r
+ if (fclose(fout) != 0) {\r
+ perror("fclose");\r
+ exit(1);\r
+ }\r
+ }\r