]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/demo_altkeys.c
ncurses 5.9 - patch 20140816
[ncurses.git] / test / demo_altkeys.c
index 001e2d14b2bba4e64bc04ed750a45bc17876990c..f2b07b1c8c90855c042fc6b8a7b9be2424e1d1cc 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 2005,2006 Free Software Foundation, Inc.                   *
+ * Copyright (c) 2005-2006,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            *
@@ -26,7 +26,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: demo_altkeys.c,v 1.7 2006/12/09 16:49:49 tom Exp $
+ * $Id: demo_altkeys.c,v 1.9 2010/11/14 00:59:26 tom Exp $
  *
  * Demonstrate the define_key() function.
  * Thomas Dickey - 2005/10/22
  *
  * Demonstrate the define_key() function.
  * Thomas Dickey - 2005/10/22
@@ -110,7 +110,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
     for (n = KEY_MIN; n < KEY_MAX; ++n) {
        char *value;
        if ((value = keybound(n, 0)) != 0) {
     for (n = KEY_MIN; n < KEY_MAX; ++n) {
        char *value;
        if ((value = keybound(n, 0)) != 0) {
-           char *temp = malloc(strlen(value) + 2);
+           char *temp = typeMalloc(char, strlen(value) + 2);
            sprintf(temp, "\033%s", value);
            define_key(temp, n + MY_KEYS);
            free(temp);
            sprintf(temp, "\033%s", value);
            define_key(temp, n + MY_KEYS);
            free(temp);
@@ -128,8 +128,8 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
 
 #if HAVE_GETTIMEOFDAY
        gettimeofday(&current, 0);
 
 #if HAVE_GETTIMEOFDAY
        gettimeofday(&current, 0);
-       secs = current.tv_sec - previous.tv_sec;
-       msecs = (current.tv_usec - previous.tv_usec) / 1000;
+       secs = (int) (current.tv_sec - previous.tv_sec);
+       msecs = (int) ((current.tv_usec - previous.tv_usec) / 1000);
        if (msecs < 0) {
            msecs += 1000;
            --secs;
        if (msecs < 0) {
            msecs += 1000;
            --secs;