diff options
| author | Louis Burda <quent.burda@gmail.com> | 2022-01-27 03:29:44 +0100 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2022-01-27 03:29:44 +0100 |
| commit | b073d4b0c2c1d4dce36adcc285ad5dfaf2f7599d (patch) | |
| tree | 253551dcba2f3798f9d6c4b6f8a9a820381eb31a /src/history.c | |
| parent | e456776063b61d339205c84bf884d0eeb761e57b (diff) | |
| download | tmus-b073d4b0c2c1d4dce36adcc285ad5dfaf2f7599d.tar.gz tmus-b073d4b0c2c1d4dce36adcc285ad5dfaf2f7599d.zip | |
New list interface for fast tail access
Diffstat (limited to 'src/history.c')
| -rw-r--r-- | src/history.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/history.c b/src/history.c index 3c45a67..a0ede46 100644 --- a/src/history.c +++ b/src/history.c @@ -4,11 +4,10 @@ #include <string.h> #include <wchar.h> - void history_init(struct history *history) { - history->list = LIST_HEAD; + list_init(&history->list); history->input = inputln_alloc(); history->sel = history->input; } @@ -41,13 +40,9 @@ history_free(struct history *history) ln = link_pop(LINK(history->input)); inputln_free(UPCAST(ln, struct inputln)); - for (iter = history->list.next; iter; ) { - next = iter->next; - inputln_free(UPCAST(iter, struct inputln)); - iter = next; - } + list_free(&history->list, (link_free_func) inputln_free, + LINK_OFFSET(struct inputln)); - history->list = LIST_HEAD; history->input = NULL; history->sel = NULL; } @@ -102,7 +97,7 @@ history_add(struct history *history, struct inputln *line) if (list_len(&history->list) == HISTORY_MAX) { /* pop last item to make space */ - back = link_pop(link_back(&history->list)); + back = list_pop_back(&history->list); inputln_free(UPCAST(back, struct inputln)); } |
