From 0a06e078319b64eca111f4d0b3b6500207a1faf1 Mon Sep 17 00:00:00 2001 From: Chris Allegretta Date: Tue, 23 Jan 2001 02:35:04 +0000 Subject: [PATCH] replace for loop for hline init with memset in init functions git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@501 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 2 ++ nano.c | 19 +++++-------------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0d05ad2c..738e90f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,6 +21,8 @@ General - Added restoration of totsize after unjustify command. usage() - Add arg to -T help (Rocco). + global_init(), handle_sigwinch() + - Messy loops replaced with memset calls (Rocco). nano 0.9.99pre1 - 01/17/2001 General diff --git a/nano.c b/nano.c index 66af04fa..a170b23f 100644 --- a/nano.c +++ b/nano.c @@ -167,8 +167,6 @@ void clear_filename(void) /* Initialize global variables - no better way for now */ void global_init(void) { - int i; - current_x = 0; current_y = 0; @@ -190,11 +188,8 @@ void global_init(void) die_too_small(); hblank = nmalloc(COLS + 1); - - /* Thanks BG for this bit... */ - for (i = 0; i <= COLS - 1; i++) - hblank[i] = ' '; - hblank[i] = 0; + memset(hblank, ' ', COLS); + hblank[COLS] = 0; } #ifndef DISABLE_HELP @@ -1543,7 +1538,6 @@ void handle_sigwinch(int s) char *tty = NULL; int fd = 0; int result = 0; - int i = 0; struct winsize win; tty = ttyname(0); @@ -1566,12 +1560,9 @@ void handle_sigwinch(int s) if ((fill = COLS - CHARS_FROM_EOL) < MIN_FILL_LENGTH) die_too_small(); - free(hblank); - hblank = nmalloc(COLS + 1); - - for (i = 0; i <= COLS - 1; i++) - hblank[i] = ' '; - hblank[i] = 0; + hblank = nrealloc(hblank, COLS + 1); + memset(hblank, ' ', COLS); + hblank[COLS] = 0; #ifdef HAVE_NCURSES_H resizeterm(LINES, COLS); -- 2.39.5