]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/trace/trace_buf.c
ncurses 5.9 - patch 20120721
[ncurses.git] / ncurses / trace / trace_buf.c
index 6345acc035fc48c37b8bf4b1c24a15b3ee9d93d6..84a7a0ce076c03c16c484c069a32ec257417b3c5 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2011,2012 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            *
@@ -35,7 +35,9 @@
 
 #include <curses.priv.h>
 
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: trace_buf.c,v 1.14 2008/08/03 15:13:56 tom Exp $")
+MODULE_ID("$Id: trace_buf.c,v 1.20 2012/02/22 22:34:31 tom Exp $")
+
+#ifdef TRACE
 
 #define MyList _nc_globals.tracebuf_ptr
 #define MySize _nc_globals.tracebuf_used
 
 #define MyList _nc_globals.tracebuf_ptr
 #define MySize _nc_globals.tracebuf_used
@@ -47,7 +49,7 @@ _nc_trace_alloc(int bufnum, size_t want)
 
     if (bufnum >= 0) {
        if ((size_t) (bufnum + 1) > MySize) {
 
     if (bufnum >= 0) {
        if ((size_t) (bufnum + 1) > MySize) {
-           size_t need = (bufnum + 1) * 2;
+           size_t need = (size_t) (bufnum + 1) * 2;
            if ((MyList = typeRealloc(TRACEBUF, need, MyList)) != 0) {
                while (need > MySize)
                    MyList[MySize++].text = 0;
            if ((MyList = typeRealloc(TRACEBUF, need, MyList)) != 0) {
                while (need > MySize)
                    MyList[MySize++].text = 0;
@@ -101,14 +103,18 @@ _nc_trace_buf(int bufnum, size_t want)
 NCURSES_EXPORT(char *)
 _nc_trace_bufcat(int bufnum, const char *value)
 {
 NCURSES_EXPORT(char *)
 _nc_trace_bufcat(int bufnum, const char *value)
 {
-    char *buffer = _nc_trace_alloc(bufnum, 0);
+    char *buffer = _nc_trace_alloc(bufnum, (size_t) 0);
     if (buffer != 0) {
        size_t have = strlen(buffer);
     if (buffer != 0) {
        size_t have = strlen(buffer);
+       size_t need = strlen(value) + have;
 
 
-       buffer = _nc_trace_alloc(bufnum, 1 + have + strlen(value));
+       buffer = _nc_trace_alloc(bufnum, 1 + need);
        if (buffer != 0)
        if (buffer != 0)
-           (void) strcpy(buffer + have, value);
+           _nc_STRCPY(buffer + have, value, need);
 
     }
     return buffer;
 }
 
     }
     return buffer;
 }
+#else
+EMPTY_MODULE(_nc_empty_trace_buf)
+#endif /* TRACE */