]> git.lizzy.rs Git - nothing.git/blobdiff - src/ui/console.c
create_lt() -> {0}
[nothing.git] / src / ui / console.c
index 8c4c8f5b987d39b8cb46bbbda749ea9ce2a930ef..3f8b7c794039252f9c7a3149011e53bc6305a15e 100644 (file)
@@ -6,8 +6,6 @@
 #include "ebisp/scope.h"
 #include "ebisp/std.h"
 #include "game/level.h"
-#include "game/level/player/rigid_rect.h"
-#include "game/level_script.h"
 #include "sdl/renderer.h"
 #include "system/log.h"
 #include "system/log_script.h"
@@ -40,7 +38,7 @@
 
 struct Console
 {
-    Lt *lt;
+    Lt lt;
     Gc *gc;
     struct Scope scope;
     Edit_field *edit_field;
@@ -58,13 +56,13 @@ struct Console
 Console *create_console(Broadcast *broadcast,
                         const Sprite_font *font)
 {
-    Lt *lt = create_lt();
+    Lt lt = {0};
 
     if (lt == NULL) {
         return NULL;
     }
 
-    Console *console = PUSH_LT(lt, nth_alloc(sizeof(Console)), free);
+    Console *console = PUSH_LT(lt, nth_calloc(1, sizeof(Console)), free);
     if (console == NULL) {
         RETURN_LT(lt, NULL);
     }
@@ -81,6 +79,7 @@ Console *create_console(Broadcast *broadcast,
 
     load_std_library(console->gc, &console->scope);
     load_log_library(console->gc, &console->scope);
+    /* TODO(#669): how to report EvalResult error from create_console? */
     broadcast_load_library(broadcast, console->gc, &console->scope);
 
     console->edit_field = PUSH_LT(
@@ -106,7 +105,7 @@ Console *create_console(Broadcast *broadcast,
 
     console->eval_result = PUSH_LT(
         lt,
-        nth_alloc(sizeof(char) * CONSOLE_EVAL_RESULT_SIZE),
+        nth_calloc(1, sizeof(char) * CONSOLE_EVAL_RESULT_SIZE),
         free);
     if (console->eval_result == NULL) {
         RETURN_LT(lt, NULL);