OSDN Git Service

Bump into issue with allocating pcx file buffer~ ><; but file reading is good but...
authorsparky4 <sparky4@cock.li>
Tue, 24 Mar 2015 16:46:07 +0000 (11:46 -0500)
committersparky4 <sparky4@cock.li>
Tue, 24 Mar 2015 16:46:07 +0000 (11:46 -0500)
modified:   scroll.exe
modified:   src/lib/bitmap.c
modified:   src/lib/mapread.c

scroll.exe
src/lib/bitmap.c
src/lib/mapread.c

index d801e2e..8d5085d 100644 (file)
Binary files a/scroll.exe and b/scroll.exe differ
index ece5f07..e6a0adb 100644 (file)
@@ -75,7 +75,7 @@ bitmapLoadPcx(char *filename) {
     bitmap_t result;\r
     long bufSize;\r
     int index;\r
-    byte count, val;\r
+    byte count, val;
 \r
     /* open the PCX file for reading */\r
     file = fopen(filename, "rb");\r
@@ -85,11 +85,11 @@ bitmapLoadPcx(char *filename) {
     }\r
 \r
     /* load the first part of the pcx file */\r
-    loadPcxStage1(file, &result);\r
+    loadPcxStage1(file, &result);
 \r
     /* allocate the buffer */\r
-    bufSize = result.width * result.height;\r
-    result.data = malloc(bufSize);\r
+    bufSize = result.width * result.height;
+    result.data = malloc(bufSize);     //it breaks right here~
     if(!result.data) {\r
        printf("Could not allocate memory for bitmap data.");\r
        fclose(file);\r
index 6a947d6..cd4f5c3 100644 (file)
@@ -164,14 +164,14 @@ again:
                        }
                } else {
                        //printf("================================================================================%s================================================================================", js);
-                       js_sv=malloc(sizeof(char)*10);
+                       //js_sv=malloc(sizeof(char)*10);
                        dump(js, tok, p.toknext, 0, map, 0);
                        eof_expected = 1;
                }
        }
 
-       //free(js);
-       //free(tok);
+       free(js);
+       free(tok);
        fclose(fh);
 
        return 0;