[dev] [st] [PATCH] Got rid of code duplication in tnew() and tresize().

From: Alexander Sedov <alex0player_AT_gmail.com>
Date: Mon, 15 Apr 2013 00:12:10 +0400

---
 st.c |   18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)
diff --git a/st.c b/st.c
index 56dc94c..fc07a46 100644
--- a/st.c
+++ b/st.c
_AT_@ -1195,22 +1195,10 @@ treset(void) {
 
 void
 tnew(int col, int row) {
-	/* set screen size */
-	term.row = row;
-	term.col = col;
-	term.line = xmalloc(term.row * sizeof(Line));
-	term.alt  = xmalloc(term.row * sizeof(Line));
-	term.dirty = xmalloc(term.row * sizeof(*term.dirty));
-	term.tabs = xmalloc(term.col * sizeof(*term.tabs));
-
-	for(row = 0; row < term.row; row++) {
-		term.line[row] = xmalloc(term.col * sizeof(Glyph));
-		term.alt [row] = xmalloc(term.col * sizeof(Glyph));
-		term.dirty[row] = 0;
-	}
-
+	/* setting "zero" terminal to resize it later */
+	memset(&term, 0, sizeof(Term));
+	tresize(col, row);
 	term.numlock = 1;
-	memset(term.tabs, 0, term.col * sizeof(*term.tabs));
 	/* setup screen */
 	treset();
 }
-- 
1.7.10.4
Received on Sun Apr 14 2013 - 22:12:10 CEST

This archive was generated by hypermail 2.3.0 : Sun Apr 14 2013 - 22:24:05 CEST