diff --git a/index.html b/index.html index 728dd3a..59f5ef7 100644 --- a/index.html +++ b/index.html @@ -3,6 +3,7 @@ -
-
- - +
+
+
+ + +
diff --git a/js-api.c b/js-api.c index a1978c4..c4af0b5 100644 --- a/js-api.c +++ b/js-api.c @@ -1,5 +1,7 @@ #include "emscripten.h" #include +#include +#include #include #include "expression.h" #include "parser.tab.h" @@ -25,13 +27,16 @@ void EMSCRIPTEN_KEEPALIVE webdice(char* str){ int length; char* in_block; char* out_block; + static char seeded = 0; - yydebug = 1; + if (!seeded){ + seeded = 1; + srand(time(NULL)); + } in_block = (char*) malloc((2 + strlen(str)) * sizeof(char)); sprintf(in_block,"%s\n",str); - yyscan_t scanner; yylex_init(&scanner); yy_scan_string (in_block, scanner); @@ -46,6 +51,8 @@ void EMSCRIPTEN_KEEPALIVE webdice(char* str){ output_print(out_block); free(out_block); + free(result.text); + free_expression(root); }else{ output_print("

Error!

"); }