projects
/
xscreensaver
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ftp://ftp.krokus.ru/pub/OpenBSD/distfiles/xscreensaver-4.06.tar.gz
[xscreensaver]
/
hacks
/
critical.c
diff --git
a/hacks/critical.c
b/hacks/critical.c
index 5a6fae2a8014324eb9422a0cc53a6befb3801e3f..5acb478d2ff58f0b0d0f94c75fa8d138e4c529eb 100644
(file)
--- a/
hacks/critical.c
+++ b/
hacks/critical.c
@@
-96,7
+96,7
@@
model_allocate (int model_w, int model_h)
model->width = model_w;
model->height = model_h;
model->width = model_w;
model->height = model_h;
- model->cells = malloc (sizeof (
in
t) * model_w * model_h);
+ model->cells = malloc (sizeof (
unsigned shor
t) * model_w * model_h);
if (!model->cells)
return 0;
if (!model->cells)
return 0;
@@
-128,7
+128,7
@@
model_initialize (CriticalModel *model)
{
int i;
{
int i;
- for (i = model->width * model->height; i >= 0; i--)
+ for (i = model->width * model->height
- 1
; i >= 0; i--)
{
model->cells[i] = (unsigned short) random ();
}
{
model->cells[i] = (unsigned short) random ();
}
@@
-237,6
+237,17
@@
setup_colormap (Display *dpy, XWindowAttributes *wattr,
}
}
+/* Free allocated colormap created by setup_colormap. */
+static void
+free_colormap (Display *dpy, XWindowAttributes *wattr,
+ XColor **colors, int n_colors)
+{
+ free_colors (dpy, wattr->colormap, *colors, n_colors);
+ free (*colors);
+}
+
+
+
/* Draw one step of the hack. Positions are cell coordinates. */
static void
draw_step (CriticalSettings *settings,
/* Draw one step of the hack. Positions are cell coordinates. */
static void
draw_step (CriticalSettings *settings,
@@
-341,6
+352,7
@@
screenhack (Display *dpy, Window window)
setup_colormap (dpy, &wattr, &colors, &n_colors);
erase_full_window (dpy, window);
model_initialize (model);
setup_colormap (dpy, &wattr, &colors, &n_colors);
erase_full_window (dpy, window);
model_initialize (model);
+ model_step (model, &history[0]);
pos = 1;
wrapped = 0;
}
pos = 1;
wrapped = 0;
}
@@
-382,5
+394,11
@@
screenhack (Display *dpy, Window window)
}
i_restart = (i_restart + 1) % n_restart;
}
i_restart = (i_restart + 1) % n_restart;
+
+ if (i_restart == 0)
+ {
+ /* Clean up after completing a simulation. */
+ free_colormap (dpy, &wattr, &colors, n_colors);
+ }
}
}
}
}