/****************************************************************************
- * 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 *
#include <curses.priv.h>
-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)
# 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)
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();
#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 */
}
#endif /* !defined(SCROLLDEBUG) && !defined(HASHDEBUG) */
}
+ TR(TRACE_ICALLS, (T_RETURN("")));
}
#if defined(TRACE) || defined(SCROLLDEBUG) || defined(HASHDEBUG)
_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) */