aboutsummaryrefslogtreecommitdiff
path: root/contrib/ncurses/test/worm.c
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>2000-07-03 09:24:12 +0000
committerPeter Wemm <peter@FreeBSD.org>2000-07-03 09:24:12 +0000
commit15589c42fa2774d2f8ee650f4f31eb8d3a861316 (patch)
tree27e79485df3c9195e6fe58960df47f675f41f1e9 /contrib/ncurses/test/worm.c
parent6b9085fd58b7602b14be0cd2059285baa764a7ee (diff)
downloadsrc-15589c42fa2774d2f8ee650f4f31eb8d3a861316.tar.gz
src-15589c42fa2774d2f8ee650f4f31eb8d3a861316.zip
Import the most recent ncurses 5.1 prerelease (20000701).
Mostly this is intended to resolve the trace() badness once and for all. Obtained from: ftp://dickey.his.com/ncurses/
Notes
Notes: svn path=/vendor/ncurses/dist/; revision=62449
Diffstat (limited to 'contrib/ncurses/test/worm.c')
-rw-r--r--contrib/ncurses/test/worm.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/contrib/ncurses/test/worm.c b/contrib/ncurses/test/worm.c
index 5f0ab5dc4a5a..43a898f84d13 100644
--- a/contrib/ncurses/test/worm.c
+++ b/contrib/ncurses/test/worm.c
@@ -34,16 +34,13 @@ Options:
traces will be dumped. The program stops and waits for one character of
input at the beginning and end of the interval.
- $Id: worm.c,v 1.26 1999/10/23 01:31:40 tom Exp $
+ $Id: worm.c,v 1.30 2000/04/15 17:51:56 tom Exp $
*/
#include <test.priv.h>
#include <signal.h>
-#define typeAlloc(type,n) (type *) malloc(n * sizeof(type))
-#define typeRealloc(type,n,p) (type *) realloc(p, n * sizeof(type))
-
static chtype flavor[] =
{
'O', '*', '#', '$', '%', '0', '@',
@@ -185,7 +182,6 @@ main(int argc, char *argv[])
short **ref;
int x, y;
int n;
- int ch;
struct worm *w;
const struct options *op;
int h;
@@ -255,7 +251,7 @@ main(int argc, char *argv[])
if (has_colors()) {
int bg = COLOR_BLACK;
start_color();
-#ifdef NCURSES_VERSION
+#ifdef HAVE_USE_DEFAULT_COLORS
if (use_default_colors() == OK)
bg = -1;
#endif
@@ -274,9 +270,9 @@ main(int argc, char *argv[])
}
#endif /* A_COLOR */
- ref = typeAlloc(short *, LINES);
+ ref = typeMalloc(short *, LINES);
for (y = 0; y < LINES; y++) {
- ref[y] = typeAlloc(short, COLS);
+ ref[y] = typeMalloc(short, COLS);
for (x = 0; x < COLS; x++) {
ref[y][x] = 0;
}
@@ -289,14 +285,14 @@ main(int argc, char *argv[])
for (n = number, w = &worm[0]; --n >= 0; w++) {
w->orientation = w->head = 0;
- if (!(ip = typeAlloc(short, (length + 1)))) {
+ if (!(ip = typeMalloc(short, (length + 1)))) {
fprintf(stderr, "%s: out of memory\n", *argv);
return EXIT_FAILURE;
}
w->xpos = ip;
for (x = length; --x >= 0;)
*ip++ = -1;
- if (!(ip = typeAlloc(short, (length + 1)))) {
+ if (!(ip = typeMalloc(short, (length + 1)))) {
fprintf(stderr, "%s: out of memory\n", *argv);
return EXIT_FAILURE;
}
@@ -338,6 +334,8 @@ main(int argc, char *argv[])
generation++;
}
#else
+ int ch;
+
if ((ch = getch()) > 0) {
#ifdef KEY_RESIZE
if (ch == KEY_RESIZE) {
@@ -350,11 +348,11 @@ main(int argc, char *argv[])
last = COLS - 1;
}
if (bottom != LINES - 1) {
- ref = typeRealloc(short *, LINES, ref);
- for (y = COLS; y <= bottom; y++)
+ for (y = LINES; y <= bottom; y++)
free(ref[y]);
+ ref = typeRealloc(short *, LINES, ref);
for (y = bottom + 1; y < LINES; y++) {
- ref[y] = typeAlloc(short, COLS);
+ ref[y] = typeMalloc(short, COLS);
for (x = 0; x < COLS; x++)
ref[y][x] = 0;
}