diff options
author | Simon Rettberg | 2019-02-18 11:55:58 +0100 |
---|---|---|
committer | Simon Rettberg | 2019-02-18 11:55:58 +0100 |
commit | aa7530630e595b80d5db54655fd827b61edc0fd7 (patch) | |
tree | 048cb74072450c7592f254c3537ac8f252d09d73 /hacks/wormhole.c | |
parent | Forgot one DPMS killing instance (diff) | |
parent | Update to 5.42 (diff) | |
download | xscreensaver-aa7530630e595b80d5db54655fd827b61edc0fd7.tar.gz xscreensaver-aa7530630e595b80d5db54655fd827b61edc0fd7.tar.xz xscreensaver-aa7530630e595b80d5db54655fd827b61edc0fd7.zip |
Merge branch 'master' into openslxv23
Diffstat (limited to 'hacks/wormhole.c')
-rw-r--r-- | hacks/wormhole.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/hacks/wormhole.c b/hacks/wormhole.c index f28c5b2..602be98 100644 --- a/hacks/wormhole.c +++ b/hacks/wormhole.c @@ -281,15 +281,13 @@ static void moveColorChanger( color_changer * ch ) } -#if 0 -static void destroyColorChanger( color_changer * ch ) +static void destroyColorChanger( struct state *st, color_changer * ch ) { int q; for ( q = 0; q < ch->max; q++ ) - XFreeColors( st->dpy, *cmap, &( ch->shade[q].pixel ), 1, 0 ); + XFreeColors( st->dpy, st->cmap, &( ch->shade[q].pixel ), 1, 0 ); free( ch->shade ); } -#endif static void resizeWormhole( struct state *st, wormhole * worm ) { @@ -353,21 +351,26 @@ static void initWormhole( struct state *st, wormhole * worm, Display * display, initColorChanger( st, &(worm->changer) ); worm->num_stars = 64; - worm->stars = (starline **)malloc( sizeof(starline *) * worm->num_stars ); - for ( i = 0; i < worm->num_stars; i++ ) + worm->stars = (starline **)calloc(sizeof(starline *), worm->num_stars); + for ( i = 0; i < worm->num_stars; i++ ) { + if (worm->stars[i]) free (worm->stars[i]); worm->stars[i] = NULL; + } } -#if 0 -static void destroyWormhole( wormhole * worm ) +static void destroyWormhole( struct state *st, wormhole * worm ) { - destroyColorChanger( &(worm->changer), st->dpy, cmap ); - if (work->work != st->window) + int i; + destroyColorChanger( st, &(worm->changer)); + if (worm->work != st->window) { XFreePixmap( st->dpy, worm->work ); - free( worm->stars ); + worm->work = 0; + } + for (i = 0; i < worm->num_stars; i++) + if (worm->stars[i]) free(worm->stars[i]); + free(worm->stars); } -#endif static double Cos( int a ) { @@ -696,6 +699,8 @@ static void wormhole_free (Display *dpy, Window window, void *closure) { struct state *st = (struct state *) closure; + destroyWormhole (st, &st->worm); + XFreeGC (dpy, st->gc); free (st); } |