Ticket #8293: rescummp.2.diff

File rescummp.2.diff, 1.4 KB (added by SF/yudhi97, 21 years ago)

patch from v1.5

Line 
119,24c19
2< *
3< * Changes by Yudhi Widyatama (yudhi@warlord.ee.itb.ac.id)
4< * - tries to continue with next file in case of out-of-memory
5< * - if cannot allocate memory for the whole file, uses a 2MB
6< * buffer in lieu of the file size (file_len) and do it
7< * with a do-while loop
8---
9> *
1053c48
11< ("error: you must specify the mac data file on the command line.\n i.e. \% rescumm \"Sam & Max Demo Data\"\n",
12---
13> ("error: you must specify the mac data file on the command line.\n i.e. \% macextract \"Sam & Max Demo Data\"\n",
14157,160c152
15< if (!(buf = malloc(file_len))) {
16< buf = malloc(2048*1024) ; // 2MB
17< if (!buf)
18< {
19---
20> if (!(buf = malloc(file_len))) {
21162,184c154,155
22< fclose(ofp);
23< } else {
24< size_t readed,total_read;
25< total_read=0; readed=0;
26< do {
27< readed = file_len - total_read;
28< if (readed>2048*1024)
29< readed = 2048*1024;
30< readed=fread(buf,1,readed,ifp);
31< if (readed>0) {
32< fwrite(buf,1,readed,ofp);
33< total_read+=readed;
34< }
35< } while (readed>0);
36< fclose(ofp);
37< free(buf);
38< fprintf(stdout,"total written = %ld bytes, file len = %ld\n",
39< total_read,file_len);
40< if (total_read!=file_len)
41< fprintf(stderr,"bytes written mismatch with file size!\n");
42< }
43< } else
44< {
45---
46> exit(0);
47> }
48188,189c159
49< free(buf);
50< }
51---
52> free(buf);