• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision4e2c950b0cf6150d4fa521cb705e503394600ada (tree)
Time2019-02-10 22:18:14
Authordhrname <dhrname@user...>
Commiterdhrname

Log Message

Modify the alloca_tokens function

Change Summary

Incremental Difference

--- a/source_code/shadowstar.c
+++ b/source_code/shadowstar.c
@@ -1350,6 +1350,19 @@ uint_fast64_t ST_readFile(ST_Char *name, ST_File_Call callback)
13501350 return (uint_fast64_t)filelength;
13511351 }
13521352
1353+/*alloca_tokens 関数
1354+ * トークン配列を作るためのアロケータ*/
1355+static inline ST_Token_Mode* alloca_tokens(uint_fast64_t filelength)
1356+{
1357+ ST_Token_Mode* s;
1358+ s = (ST_Token_Mode*) ST_emalloc(sizeof(ST_Token_Mode) * filelength);
1359+ for (uint_fast64_t i = 0; i<filelength; i++)
1360+ {
1361+ s[i] = ST_UNKNOWN_TOKEN;
1362+ }
1363+ return s;
1364+}
1365+
13531366 /*ST_main 関数
13541367 * 引数sはソースコードの文字列。
13551368 * 引数filelengthはsの長さ
@@ -1357,7 +1370,7 @@ uint_fast64_t ST_readFile(ST_Char *name, ST_File_Call callback)
13571370 void ST_main(ST_Char* s, uint_fast64_t filelength)
13581371 {
13591372
1360- ST_Token_Mode tokens[100] = {0};
1373+ ST_Token_Mode* tokens = alloca_tokens(filelength);
13611374 size_t length = sizeof(tokens) / sizeof(tokens[0]);
13621375 ST_Ordered_Pair *varlist = ST_tokenize(s, tokens);
13631376
Binary files a/source_code/shadowstar.o and b/source_code/shadowstar.o differ
--- a/source_code/startest.c
+++ b/source_code/startest.c
@@ -913,6 +913,8 @@ int tests_invalid() {
913913
914914 assert(ST_FILE_FAIL == ST_readFile(NULL, tests_callback_file));
915915
916+ ST_main(u8"w\np\n", 1048576);
917+
916918 printf("ended error test...\n");
917919
918920 return 0;
Binary files a/source_code/startest.o and b/source_code/startest.o differ