X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=hacks%2Fcoral.c;h=55186747327297fbe731753507d061b0c3815064;hp=8ace44d2c1e6787baa00bdca88b0448b4facf269;hb=ce3185de9d9705e259f2b60dd4b5509007fa17d4;hpb=481b95e2617b69e6fd4444432747d7e1e0c3dc85 diff --git a/hacks/coral.c b/hacks/coral.c index 8ace44d2..55186747 100644 --- a/hacks/coral.c +++ b/hacks/coral.c @@ -21,12 +21,12 @@ static int ncolors = 0; static int colorindex = 0; static int colorsloth; -static XPoint *walkers; +static XPoint *walkers = 0; static int nwalkers; static int width, widthb; static int height; -static unsigned int *board; +static unsigned int *board = 0; #define getdot(x,y) (board[(y*widthb)+(x>>5)] & (1<<(x & 31))) #define setdot(x,y) (board[(y*widthb)+(x>>5)] |= (1<<(x & 31))) @@ -47,6 +47,7 @@ init_coral(Display *dpy, Window window) width = xgwa.width; widthb = ((xgwa.width + 31) >> 5); height = xgwa.height; + if (board) free(board); board = (unsigned int *)calloc(widthb * xgwa.height, sizeof(unsigned int)); if(!board) exit(1); cmap = xgwa.colormap; @@ -73,6 +74,7 @@ init_coral(Display *dpy, Window window) if( density < 1 ) density = 1; if( density > 100 ) density = 90; /* more like mold than coral */ nwalkers = (width*height*density)/100; + if (walkers) free(walkers); walkers = (XPoint *)calloc(nwalkers, sizeof(XPoint)); if( (XPoint *)0 == walkers ) exit(1);