1 | 19,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 | > *
|
---|
10 | 53c48
|
---|
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",
|
---|
14 | 157,160c152
|
---|
15 | < if (!(buf = malloc(file_len))) {
|
---|
16 | < buf = malloc(2048*1024) ; // 2MB
|
---|
17 | < if (!buf)
|
---|
18 | < {
|
---|
19 | ---
|
---|
20 | > if (!(buf = malloc(file_len))) {
|
---|
21 | 162,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 | > }
|
---|
48 | 188,189c159
|
---|
49 | < free(buf);
|
---|
50 | < }
|
---|
51 | ---
|
---|
52 | > free(buf);
|
---|