]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tty/hardscroll.c
ncurses 5.6 - patch 20080920
[ncurses.git] / ncurses / tty / hardscroll.c
index 0b227a109dcfba7b9a9c0ecef472b8bc53c4c5b1..2c40997fb6b1c090f5932458b2e72736f61d1b78 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2007,2008 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            *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -29,6 +29,8 @@
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *     and: Thomas E. Dickey                        1996-on                 *
+ *     and: Alexander V Lukyanov                    1997-1998               *
  ****************************************************************************/
 
 /******************************************************************************
  ****************************************************************************/
 
 /******************************************************************************
@@ -145,7 +147,7 @@ AUTHOR
 
 #include <curses.priv.h>
 
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: hardscroll.c,v 1.40 2007/06/30 21:11:01 tom Exp $")
+MODULE_ID("$Id: hardscroll.c,v 1.42 2008/08/03 23:49:30 tom Exp $")
 
 #if defined(SCROLLDEBUG) || defined(HASHDEBUG)
 
 
 #if defined(SCROLLDEBUG) || defined(HASHDEBUG)
 
@@ -158,7 +160,7 @@ oldnums[MAXLINES];
 # undef TR
 # define TR(n, a)      if (_nc_tracing & (n)) { _tracef a ; putchar('\n'); }
 
 # undef TR
 # define TR(n, a)      if (_nc_tracing & (n)) { _tracef a ; putchar('\n'); }
 
-extern NCURSES_EXPORT_VAR(unsigned)     _nc_tracing;
+extern NCURSES_EXPORT_VAR(unsigned) _nc_tracing;
 
 #else /* no debug */
 
 
 #else /* no debug */
 
@@ -204,8 +206,10 @@ _nc_scroll_optimize(void)
 #endif /* !defined(SCROLLDEBUG) && !defined(HASHDEBUG) */
 
 #ifdef TRACE
 #endif /* !defined(SCROLLDEBUG) && !defined(HASHDEBUG) */
 
 #ifdef TRACE
-    if (_nc_tracing & (TRACE_UPDATE | TRACE_MOVE))
+    if (USE_TRACEF(TRACE_UPDATE | TRACE_MOVE)) {
        _nc_linedump();
        _nc_linedump();
+       _nc_unlock_global(tracef);
+    }
 #endif /* TRACE */
 
     /* pass 1 - from top to bottom scrolling up */
 #endif /* TRACE */
 
     /* pass 1 - from top to bottom scrolling up */
@@ -268,13 +272,14 @@ _nc_linedump(void)
     char *buf = 0;
     size_t want = (screen_lines + 1) * 4;
 
     char *buf = 0;
     size_t want = (screen_lines + 1) * 4;
 
-    buf = typeMalloc(char, want);
+    if ((buf = typeMalloc(char, want)) != 0) {
 
 
-    (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));
-    free(buf);
+       (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));
+       free(buf);
+    }
 }
 #endif /* defined(TRACE) || defined(SCROLLDEBUG) */
 
 }
 #endif /* defined(TRACE) || defined(SCROLLDEBUG) */