static int cmdbuf_pos = 0;
static int cmdbuf_len = 0;
+#define HISTORY_MAX 100
+
struct edit_history {
struct dl_list list;
char str[1];
static void history_add(const char *str)
{
- struct edit_history *h, *match = NULL;
- size_t len;
+ struct edit_history *h, *match = NULL, *last = NULL;
+ size_t len, count = 0;
if (str[0] == '\0')
return;
match = h;
break;
}
+ last = h;
+ count++;
}
if (match) {
return;
}
+ if (count >= HISTORY_MAX && last) {
+ dl_list_del(&last->list);
+ os_free(last);
+ }
+
len = os_strlen(str);
h = os_zalloc(sizeof(*h) + len);
if (h == NULL)