From http://www.jwz.org/xscreensaver/xscreensaver-5.35.tar.gz
[xscreensaver] / hacks / critical.c
index 6f9fa76061320a06e908cc47a3a003eef3083f5d..81fd0c1a1056547e789302e5082bb4f03541f596 100644 (file)
@@ -100,8 +100,10 @@ model_allocate (int model_w, int model_h)
   mm->height = model_h;
 
   mm->cells = malloc (sizeof (unsigned short) * model_w * model_h);
-  if (!mm->cells)
+  if (!mm->cells) {
+    free (mm);
     return 0;
+  }
 
   return mm;
 }
@@ -216,21 +218,21 @@ setup_colormap (struct state *st, XColor **colors, int *n_colors)
   
   if (!strcmp (color_scheme, "random"))
     {
-      make_random_colormap (st->dpy, st->wattr.visual,
+      make_random_colormap (st->wattr.screen, st->wattr.visual,
                            st->wattr.colormap,
                            *colors, n_colors,
                            True, True, &writable, True);
     }
   else if (!strcmp (color_scheme, "smooth"))
     {
-      make_smooth_colormap (st->dpy, st->wattr.visual,
+      make_smooth_colormap (st->wattr.screen, st->wattr.visual,
                            st->wattr.colormap,
                            *colors, n_colors,
                            True, &writable, True);
     }
   else 
     {
-      make_uniform_colormap (st->dpy, st->wattr.visual,
+      make_uniform_colormap (st->wattr.screen, st->wattr.visual,
                             st->wattr.colormap,
                             *colors, n_colors, True,
                             &writable, True);
@@ -242,7 +244,7 @@ setup_colormap (struct state *st, XColor **colors, int *n_colors)
 static void
 free_colormap (struct state *st, XColor **colors, int n_colors)
 {
-  free_colors (st->dpy, st->wattr.colormap, *colors, n_colors);
+  free_colors (st->wattr.screen, st->wattr.colormap, *colors, n_colors);
   free (*colors);
 }
 
@@ -290,7 +292,7 @@ critical_init (Display *dpy, Window window)
   model_w = 80;
   st->settings.cell_size = st->wattr.width / model_w;
   model_h = st->settings.cell_size ?
-    st->wattr.height / st->settings.cell_size : 0;
+    st->wattr.height / st->settings.cell_size : 1;
 
   /* Construct the initial model state. */
 
@@ -319,7 +321,7 @@ critical_init (Display *dpy, Window window)
 
   st->fgc = XCreateGC (st->dpy, st->window, 0, &st->gcv);
 
-#ifdef HAVE_COCOA
+#ifdef HAVE_JWXYZ
   jwxyz_XSetAntiAliasing (dpy, st->fgc, False);
   jwxyz_XSetAntiAliasing (dpy, st->bgc, False);
 #endif