summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2021-03-07 11:17:43 +0200
committerToomas Soome <tsoome@me.com>2021-03-12 09:04:23 +0200
commit835b861bfa01968a312484d1d7bd1798865ea383 (patch)
treeda1d6c090a83469125cbde3432dd56bda2c5fe1d
parentba2848d4cb17292e88f04f6a47e0b3305f17efa7 (diff)
downloadillumos-joyent-835b861bfa01968a312484d1d7bd1798865ea383.tar.gz
13608 tem: use dynamic array for tab stops
Reviewed by: Yuri Pankov <yuripv@yuripv.dev> Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r--usr/src/uts/common/io/tem.c8
-rw-r--r--usr/src/uts/common/io/tem_safe.c10
-rw-r--r--usr/src/uts/common/sys/tem_impl.h6
3 files changed, 15 insertions, 9 deletions
diff --git a/usr/src/uts/common/io/tem.c b/usr/src/uts/common/io/tem.c
index 525aa5f585..b91952fc32 100644
--- a/usr/src/uts/common/io/tem.c
+++ b/usr/src/uts/common/io/tem.c
@@ -236,6 +236,10 @@ tem_internal_init(struct tem_vt_state *ptem, cred_t *credp,
ptem->tvs_screen_rows = kmem_alloc(ptem->tvs_screen_history_size *
sizeof (term_char_t *), KM_SLEEP);
+ ptem->tvs_maxtab = width / 8;
+ ptem->tvs_tabs = kmem_alloc(ptem->tvs_maxtab * sizeof (*ptem->tvs_tabs),
+ KM_SLEEP);
+
tem_safe_reset_display(ptem, credp, CALLED_FROM_NORMAL,
clear_screen, init_color);
@@ -340,6 +344,10 @@ tem_free_buf(struct tem_vt_state *tem)
kmem_free(tem->tvs_screen_rows, tem->tvs_screen_history_size *
sizeof (term_char_t *));
}
+ if (tem->tvs_tabs != NULL) {
+ kmem_free(tem->tvs_tabs, tem->tvs_maxtab *
+ sizeof (*tem->tvs_tabs));
+ }
}
void
diff --git a/usr/src/uts/common/io/tem_safe.c b/usr/src/uts/common/io/tem_safe.c
index 8764c5764e..73f4604519 100644
--- a/usr/src/uts/common/io/tem_safe.c
+++ b/usr/src/uts/common/io/tem_safe.c
@@ -1961,7 +1961,7 @@ static void
tem_safe_tab(struct tem_vt_state *tem,
cred_t *credp, enum called_from called_from)
{
- int i;
+ size_t i;
screen_pos_t tabstop;
ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
@@ -1983,10 +1983,9 @@ tem_safe_tab(struct tem_vt_state *tem,
static void
tem_safe_set_tab(struct tem_vt_state *tem)
{
- int i;
- int j;
+ size_t i, j;
- if (tem->tvs_ntabs == TEM_MAXTAB)
+ if (tem->tvs_ntabs == tem->tvs_maxtab)
return;
if (tem->tvs_ntabs == 0 ||
tem->tvs_tabs[tem->tvs_ntabs] < tem->tvs_c_cursor.col) {
@@ -2009,8 +2008,7 @@ tem_safe_set_tab(struct tem_vt_state *tem)
static void
tem_safe_clear_tabs(struct tem_vt_state *tem, int action)
{
- int i;
- int j;
+ size_t i, j;
switch (action) {
case 3: /* clear all tabs */
diff --git a/usr/src/uts/common/sys/tem_impl.h b/usr/src/uts/common/sys/tem_impl.h
index eeb5881a22..d039e4279b 100644
--- a/usr/src/uts/common/sys/tem_impl.h
+++ b/usr/src/uts/common/sys/tem_impl.h
@@ -77,7 +77,6 @@ extern "C" {
#define TEM_ATTR_ISSET(c, a) ((TEM_CHAR_ATTR(c) & (a)) == (a))
#define TEM_MAXPARAMS 5 /* maximum number of ANSI paramters */
-#define TEM_MAXTAB 40 /* maximum number of tab stops */
#define TEM_MAXFKEY 30 /* max length of function key with <ESC>Q */
#define TEM_SCROLL_UP 0
@@ -187,8 +186,9 @@ struct tem_vt_state {
int tvs_curparam; /* current param # of output esc seq */
int tvs_paramval; /* value of current param */
int tvs_params[TEM_MAXPARAMS]; /* parameters of output esc seq */
- screen_pos_t tvs_tabs[TEM_MAXTAB]; /* tab stops */
- int tvs_ntabs; /* number of tabs used */
+ screen_pos_t *tvs_tabs; /* tab stops */
+ size_t tvs_maxtab; /* maximum number of tab stops */
+ size_t tvs_ntabs; /* number of tabs used */
int tvs_nscroll; /* number of lines to scroll */
struct tem_char_pos tvs_s_cursor; /* start cursor position */