]> 4ch.mooo.com Git - 16.git/commitdiff
fucking shit!
authorsparky4 <sparky4@cock.li>
Sun, 22 Mar 2015 23:55:52 +0000 (18:55 -0500)
committersparky4 <sparky4@cock.li>
Sun, 22 Mar 2015 23:55:52 +0000 (18:55 -0500)
modified:   src/lib/jsmn/example/MAPTEST.EXE
modified:   src/lib/jsmn/example/maptest.c

src/lib/jsmn/example/MAPTEST.EXE
src/lib/jsmn/example/maptest.c

index a9a86352e2a57083f3e287c5017c81728dea1c55..b9a3eb59322ba5bad5c7f9761487f2097d7fede0 100644 (file)
Binary files a/src/lib/jsmn/example/MAPTEST.EXE and b/src/lib/jsmn/example/MAPTEST.EXE differ
index 2fdf04e0871f9f91f236a99ba1041fd4604e8213..7c305bffe770e00ca94102b78440697f7ece1520 100644 (file)
@@ -39,13 +39,13 @@ int main() {
        jsmn_parser p;
        jsmntok_t t[2048]; /* We expect no more than 128 tokens */
        FILE *fh = fopen("../../../../data/test.map", "r");
-
        char *json_string = malloc(filesize(fh));
        //memset(json_string, 0, sizeof(*json_string));
 
        if(fh != NULL)
        {
                z = fread(json_string, 1, filesize(fh), fh);
+               fclose(fh); fh = NULL;
                printf("[[%d]]\n", z);
                json_string[z] = '\0';
                // we can now close the file
@@ -54,10 +54,8 @@ int main() {
                //printf("[[%s]]\n", json_string);
 
        jsmn_init(&p);
+       r = jsmn_parse(&p, json_string, z, t, sizeof(t)/sizeof(t[0]));
        printf("[\n%s\n]", json_string);
-       r = jsmn_parse(&p, json_string, filesize(fh), t, sizeof(t)/sizeof(t[0]));
-               fclose(fh); fh = NULL;
-       //printf("[\n%s\n]", json_string);
        if (r < 0) {
                printf("Failed to parse JSON: %d\n", r);
                return 1;