]> git.lizzy.rs Git - nothing.git/blobdiff - src/ui/history.c
`Lt *` -> `Lt `
[nothing.git] / src / ui / history.c
index cddf5d394654c7efee29c5d1f248d1940df55d7c..935e88d99db6010394e1630e42f66db1191ad68d 100644 (file)
@@ -1,15 +1,15 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <assert.h>
+#include "system/stacktrace.h"
 
 #include "history.h"
-#include "str.h"
+#include "system/str.h"
 #include "system/lt.h"
 #include "system/nth_alloc.h"
 
 struct History
 {
-    Lt *lt;
+    Lt lt;
 
     char **buffer;
     size_t begin;
@@ -19,14 +19,14 @@ struct History
 
 History *create_history(size_t capacity)
 {
-    Lt *lt = create_lt();
+    Lt lt = create_lt();
     if (lt == NULL) {
         return NULL;
     }
 
     History *history = PUSH_LT(
         lt,
-        nth_alloc(sizeof(History)),
+        nth_calloc(1, sizeof(History)),
         free);
     if (history == NULL) {
         RETURN_LT(lt, NULL);
@@ -47,7 +47,7 @@ History *create_history(size_t capacity)
 
 void destroy_history(History *history)
 {
-    assert(history);
+    trace_assert(history);
 
     for (size_t i = 0; i < history->capacity; ++i) {
         if (history->buffer[i] != NULL) {
@@ -60,8 +60,8 @@ void destroy_history(History *history)
 
 int history_push(History *history, const char *command)
 {
-    assert(history);
-    assert(command);
+    trace_assert(history);
+    trace_assert(command);
 
     const size_t next_begin = (history->begin + 1) % history->capacity;
 
@@ -83,13 +83,13 @@ int history_push(History *history, const char *command)
 
 const char *history_current(History *history)
 {
-    assert(history);
+    trace_assert(history);
     return history->buffer[history->cursor];
 }
 
 void history_prev(History *history)
 {
-    assert(history);
+    trace_assert(history);
     if (history->cursor == 0) {
         history->cursor = history->capacity - 1;
     } else {
@@ -99,6 +99,6 @@ void history_prev(History *history)
 
 void history_next(History *history)
 {
-    assert(history);
+    trace_assert(history);
     history->cursor = (history->cursor + 1) % history->capacity;
 }