X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=hacks%2Fforest.c;h=bd1e0cea694d389bfa4be2f4ac38d2a79f458124;hp=23392c741da996ef2fc06d8d7f10baf0f6832b3e;hb=4361b69d3178d7fc98d0388f9a223af6c2651aba;hpb=d6b0217f2417bd19187f0ebc389d6c5c2233b11c diff --git a/hacks/forest.c b/hacks/forest.c index 23392c74..bd1e0cea 100644 --- a/hacks/forest.c +++ b/hacks/forest.c @@ -33,6 +33,7 @@ # include "xlockmore.h" /* from the xscreensaver distribution */ # define refresh_trees 0 +# define release_trees 0 # define reshape_trees 0 # define trees_handle_event 0 #else /* !STANDALONE */ @@ -68,17 +69,12 @@ static long colorV[12] = {0x0a0000, 0x0a0500, 0x0a0a00, 0x050a00, ENTRYPOINT void init_trees(ModeInfo * mi) { - unsigned long pixels[20]; treestruct *tree; Display *display = MI_DISPLAY(mi); GC gc = MI_GC(mi); int i; if (trees == NULL) { - trees = (treestruct *) calloc(MI_NUM_SCREENS(mi), sizeof (treestruct)); - if (trees == NULL) { - return; - } if (mi->npixels > 20) { printf("%d colors selected. Setting limit to 20...\n", mi->npixels); @@ -117,6 +113,8 @@ init_trees(ModeInfo * mi) XSetForeground(display, gc, colors[1].pixel); } + MI_INIT (mi, trees, 0); + XClearWindow(display, MI_WINDOW(mi)); XSetLineAttributes(display, gc, 2, LineSolid, CapButt, JoinMiter); tree = &trees[MI_SCREEN(mi)]; @@ -132,12 +130,7 @@ init_trees(ModeInfo * mi) colors[i].flags = DoRed | DoGreen | DoBlue; } - for (i = 0; i < color; i++) - pixels[i] = colors[i].pixel; - - XFreeColors(display, mi->xgwa.colormap, pixels, mi->npixels, 0L); - - for (i = 0; i < mi->npixels; i++) + for (i = 0; i < mi->npixels; i++) if (!XAllocColor(display, mi->xgwa.colormap, &colors[i])) break; color = i; @@ -248,13 +241,4 @@ draw_trees(ModeInfo * mi) } -ENTRYPOINT void -release_trees(ModeInfo * mi) -{ - if (trees != NULL) { - (void) free((void *) trees); - trees = NULL; - } -} - XSCREENSAVER_MODULE_2 ("Forest", forest, trees)