From: sparky4 Date: Tue, 2 Jun 2015 20:05:10 +0000 (-0500) Subject: major problem with allocation huge data... X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=4448398b83f88683f07e18e1d8ab5ffbf56ce5cb;p=16.git major problem with allocation huge data... modified: maptest.exe modified: maptest.out modified: maptest0.exe modified: scroll.exe modified: src/lib/mapread.c modified: src/lib/mapread.h modified: src/maptest0.c --- diff --git a/maptest.exe b/maptest.exe index a772c37b..a72ce6c4 100644 Binary files a/maptest.exe and b/maptest.exe differ diff --git a/maptest.out b/maptest.out index 8b67a75a..8efbac5e 100644 --- a/maptest.out +++ b/maptest.out @@ -30,9 +30,9 @@ map.height= 30 1081[01]1082[01]1083[01]1084[01]1085[01]1086[01]1087[01]1088[01]1089[01]1090[01]1091[01]1092[01]1093[01]1094[01]1095[01]1096[01]1097[01]1098[01]1099[01]1100[01]1101[01]1102[01]1103[01]1104[01]1105[01]1106[01]1107[00]1108[00]1109[00]1110[00]1111[00]1112[00]1113[00]1114[00]1115[01]1116[01]1117[01]1118[01]1119[01]1120[01] 1121[01]1122[01]1123[01]1124[01]1125[01]1126[01]1127[01]1128[01]1129[01]1130[01]1131[01]1132[01]1133[01]1134[01]1135[01]1136[01]1137[01]1138[01]1139[01]1140[01]1141[01]1142[01]1143[01]1144[01]1145[01]1146[01]1147[01]1148[01]1149[01]1150[01]1151[01]1152[01]1153[01]1154[01]1155[01]1156[01]1157[01]1158[10]1159[10]1160[01] 1161[01]1162[01]1163[01]1164[01]1165[01]1166[01]1167[01]1168[01]1169[01]1170[01]1171[01]1172[01]1173[01]1174[01]1175[01]1176[01]1177[01]1178[01]1179[01]1180[01]1181[01]1182[01]1183[01]1184[01]1185[01]1186[01]1187[01]1188[01]1189[01]1190[01]1191[01]1192[01]1193[01]1194[01]1195[01]1196[01]1197[01]1198[10]1199[10] -&map==0cd9:1858 -&map.tiles==1cda:002c +&map==0cc4:1858 +&map.tiles==1cc5:002c &map.width==0000:0028 &map.height==0000:001e -&map.data==2501:0000 +&map.data==24ec:0000 okies~ diff --git a/maptest0.exe b/maptest0.exe index e58d6828..1e49bccf 100644 Binary files a/maptest0.exe and b/maptest0.exe differ diff --git a/scroll.exe b/scroll.exe index 0968b28b..d61f7169 100644 Binary files a/scroll.exe and b/scroll.exe differ diff --git a/src/lib/mapread.c b/src/lib/mapread.c index 09c7ba46..c3ebab7f 100644 --- a/src/lib/mapread.c +++ b/src/lib/mapread.c @@ -9,8 +9,9 @@ int jsoneq(const char huge *json, jsmntok_t huge *tok, const char huge *s) { } //this function is quite messy ^^; sorry! it is a quick and dirty fix~ -int dump(const char huge *js, jsmntok_t huge *t, size_t count, int indent, char *js_sv, map_t huge *map, int q) { - int i, j, k; +word dump(const char huge *js, jsmntok_t huge *t, size_t count, word indent, char *js_sv, map_t *map, unsigned long q) { + unsigned long i; + word j;//, k; bitmap_t bp; #ifdef DEBUG_JS if(indent==0) @@ -20,6 +21,8 @@ int dump(const char huge *js, jsmntok_t huge *t, size_t count, int indent, char } #endif #ifdef DEBUG_DUMPVARS + fprintf(stdout, "t->size=[%d] ", t->size); + fprintf(stdout, "q=[%d] ", q); fprintf(stdout, "indent= [%d] ", indent); fprintf(stdout, "js_sv= [%s]\n", js_sv); #endif @@ -27,6 +30,7 @@ int dump(const char huge *js, jsmntok_t huge *t, size_t count, int indent, char return 0; } /* We may want to do strtol() here to get numeric value */ +//0000fprintf(stderr, "t->type=%d\n", t->type); if (t->type == JSMN_PRIMITIVE) { if(_fstrstr(js_sv, "data")) { @@ -122,7 +126,7 @@ int dump(const char huge *js, jsmntok_t huge *t, size_t count, int indent, char int loadmap(char *mn, map_t *map) { int r; - static int incr=0; + static word incr=0; int eof_expected = 0; char huge *js = NULL; size_t jslen = 0; @@ -140,6 +144,7 @@ int loadmap(char *mn, map_t *map) jsmn_init(&p); /* Allocate some tokens as a start */ +//0000fprintf(stderr, "tok malloc\n"); tok = _fmalloc(sizeof(*tok) * tokcount); if (tok == NULL) { fprintf(stderr, "malloc(): errno=%d\n", errno); @@ -148,6 +153,7 @@ int loadmap(char *mn, map_t *map) for (;;) { /* Read another chunk */ +//0000fprintf(stderr, "read\n"); r = fread(buf, 1, sizeof(buf), fh); if (r < 0) { fprintf(stderr, "fread(): %d, errno=%d\n", r, errno); @@ -161,6 +167,8 @@ int loadmap(char *mn, map_t *map) return 2; } } +//0000fprintf(stdout, "r= [%d] BUFSIZ=%d\n", r, BUFSIZ); +//0000fprintf(stderr, "js alloc~\n"); js = _frealloc(js, jslen + r + 1); if (js == NULL) { fprintf(stderr, "*js=%Fp\n", *js); @@ -171,10 +179,13 @@ int loadmap(char *mn, map_t *map) jslen = jslen + r; again: +//fprintf(stdout, " parse~ tok=%zu jslen=%zu r=%d _memavl()=%u BUFSIZ=%d~\n", tokcount, jslen, r, _memavl(), BUFSIZ); r = jsmn_parse(&p, js, jslen, tok, tokcount); +//0000fprintf(stdout, "r= [%d]\n", r); if (r < 0) { if (r == JSMN_ERROR_NOMEM) { tokcount = tokcount * 2; +//0000fprintf(stderr, "tok realloc~ %zu\n", tokcount); tok = _frealloc(tok, sizeof(*tok) * tokcount); if (tok == NULL) { fprintf(stderr, "realloc(): errno=%d\n", errno); diff --git a/src/lib/mapread.h b/src/lib/mapread.h index eb75663e..e607cf9b 100644 --- a/src/lib/mapread.h +++ b/src/lib/mapread.h @@ -11,7 +11,7 @@ #include "src/lib/lib_head.h" //#define DEBUG_MAPDATA -#define DEBUG_MAPVAR +//#define DEBUG_MAPVAR //#define DEBUG_DUMPVARS //#define DEBUG_JS @@ -31,7 +31,7 @@ typedef struct { } map_t; int jsoneq(const char huge *json, jsmntok_t huge *tok, const char huge *s); -int dump(const char huge *js, jsmntok_t huge *t, size_t count, int indent, char *js_sv, map_t huge *map, int q); +word dump(const char huge *js, jsmntok_t huge *t, size_t count, word indent, char *js_sv, map_t *map, unsigned long q); int loadmap(char *mn, map_t *map); #endif/*_LIBMAPREAD_H_*/ diff --git a/src/maptest0.c b/src/maptest0.c index b682eb02..e0ca320c 100644 --- a/src/maptest0.c +++ b/src/maptest0.c @@ -1,7 +1,7 @@ #include #include "src/lib/mapread.h" -#define DUMP +//#define DUMP //#define DUMP_MAP void