]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/mapread.c
Bump into issue with allocating pcx file buffer~ ><; but file reading is good but...
[16.git] / src / lib / mapread.c
index de1515a4ca8c994756ee0d21c0cf8ad60af5c72b..cd4f5c30222df31186c55e183dff1a1360934a6a 100644 (file)
@@ -29,7 +29,7 @@ static int dump(const char *js, jsmntok_t *t, size_t count, int indent, /*char *
                        //bgdata[q] = strtol(js+t->start, (char **)js+t->end, 10);
                        //if(strtol(js+t->start, (char **)js+t->end, 10)==0){ /*printf("%d\n", sizeof(map->tiles->data->data));*/ fprintf(stderr, "\nFACK! %d\n", errno); exit(-1); }
                        //printf("%.*s", (t-1)->end - (t-1)->start, js+(t-1)->start);
-                       map->tiles->data->data[q] = (byte)strtol(js+t->start, (char **)js+t->end, 0);
+                       map->tiles->data->data[q] = (byte)strtol(js+t->start, &(char *)t->end, 0);
                        printf("[%d]", map->tiles->data->data[q]);
                }
                else
@@ -37,7 +37,7 @@ static int dump(const char *js, jsmntok_t *t, size_t count, int indent, /*char *
                {
                        //map->height = (int)malloc(sizeof(int));
                        map->height = (int)strtol(js+t->start, (char **)js+t->end, 10);
-                       printf("h:[%d]\n", map->height);
+                       //printf("h:[%d]\n", map->height);
                }else if(js_sv == "width")
                {
                        //map->width = (int)malloc(sizeof(int));
@@ -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;