X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftty%2Fhardscroll.c;h=7d8979a4f51b12a6071533bcd02bae6bdb1c782e;hp=7815db75ae37989810d85c63838e06b658bd38c1;hb=6209b84e2f9cc5a53527760499be2cba5fc4e95c;hpb=46722468f47c2b77b3987729b4bcf2321cccfd01 diff --git a/ncurses/tty/hardscroll.c b/ncurses/tty/hardscroll.c index 7815db75..7d8979a4 100644 --- a/ncurses/tty/hardscroll.c +++ b/ncurses/tty/hardscroll.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000 Free Software Foundation, Inc. * + * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -145,7 +145,7 @@ AUTHOR #include -MODULE_ID("$Id: hardscroll.c,v 1.36 2001/01/14 00:17:28 tom Exp $") +MODULE_ID("$Id: hardscroll.c,v 1.41 2007/09/29 21:48:36 tom Exp $") #if defined(SCROLLDEBUG) || defined(HASHDEBUG) @@ -158,22 +158,25 @@ oldnums[MAXLINES]; # undef TR # define TR(n, a) if (_nc_tracing & (n)) { _tracef a ; putchar('\n'); } +extern NCURSES_EXPORT_VAR(unsigned) _nc_tracing; + #else /* no debug */ /* OLDNUM(n) indicates which line will be shifted to the position n. if OLDNUM(n) == _NEWINDEX, then the line n in new, not shifted from somewhere. */ NCURSES_EXPORT_VAR(int *) -_nc_oldnums = 0; +_nc_oldnums = 0; /* obsolete: keep for ABI compat */ # if USE_HASHMAP - static int oldnums_allocated = 0; -# define oldnums _nc_oldnums +# define oldnums SP->_oldnum_list # define OLDNUM(n) oldnums[n] # else /* !USE_HASHMAP */ # define OLDNUM(n) newscr->_line[n].oldindex # endif /* !USE_HASHMAP */ +#define OLDNUM_SIZE SP->_oldnum_size + #endif /* defined(SCROLLDEBUG) || defined(HASHDEBUG) */ NCURSES_EXPORT(void) @@ -183,17 +186,17 @@ _nc_scroll_optimize(void) int i; int start, end, shift; - TR(TRACE_ICALLS, ("_nc_scroll_optimize() begins")); + TR(TRACE_ICALLS, (T_CALLED("_nc_scroll_optimize"))); #if !defined(SCROLLDEBUG) && !defined(HASHDEBUG) #if USE_HASHMAP /* get enough storage */ - if (oldnums_allocated < screen_lines) { + if (OLDNUM_SIZE < screen_lines) { int *new_oldnums = typeRealloc(int, screen_lines, oldnums); if (!new_oldnums) return; oldnums = new_oldnums; - oldnums_allocated = screen_lines; + OLDNUM_SIZE = screen_lines; } /* calculate the indices */ _nc_hash_map(); @@ -201,8 +204,10 @@ _nc_scroll_optimize(void) #endif /* !defined(SCROLLDEBUG) && !defined(HASHDEBUG) */ #ifdef TRACE - if (_nc_tracing & (TRACE_UPDATE | TRACE_MOVE)) + if (USE_TRACEF(TRACE_UPDATE | TRACE_MOVE)) { _nc_linedump(); + _nc_unlock_global(tracef); + } #endif /* TRACE */ /* pass 1 - from top to bottom scrolling up */ @@ -253,6 +258,7 @@ _nc_scroll_optimize(void) } #endif /* !defined(SCROLLDEBUG) && !defined(HASHDEBUG) */ } + TR(TRACE_ICALLS, (T_RETURN(""))); } #if defined(TRACE) || defined(SCROLLDEBUG) || defined(HASHDEBUG) @@ -260,23 +266,17 @@ NCURSES_EXPORT(void) _nc_linedump(void) /* dump the state of the real and virtual oldnum fields */ { - static size_t have; - static char *buf; - int n; + char *buf = 0; size_t want = (screen_lines + 1) * 4; - if (have < want) - buf = typeMalloc(char, have = want); + buf = typeMalloc(char, want); (void) strcpy(buf, "virt"); for (n = 0; n < screen_lines; n++) (void) sprintf(buf + strlen(buf), " %02d", OLDNUM(n)); TR(TRACE_UPDATE | TRACE_MOVE, (buf)); -#if NO_LEAKS free(buf); - have = 0; -#endif } #endif /* defined(TRACE) || defined(SCROLLDEBUG) */