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/bubbles.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/bubbles.c')
-rw-r--r-- | hacks/bubbles.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/hacks/bubbles.c b/hacks/bubbles.c index 9cb2678..eefe048 100644 --- a/hacks/bubbles.c +++ b/hacks/bubbles.c @@ -129,7 +129,7 @@ struct state { #ifdef FANCY_BUBBLES int num_bubble_pixmaps; - Bubble_Step **step_pixmaps; + Bubble_Step **step_pixmaps, **def_list; #endif Bool simple; @@ -1214,6 +1214,8 @@ default_to_pixmaps (struct state *st) init_default_bubbles(); + st->def_list = (Bubble_Step **)xmalloc((num_default_bubbles + 1) * + sizeof(Bubble_Step *)); for (i = 0; i < num_default_bubbles; i++) { newpix = (Bubble_Step *)xmalloc(sizeof(Bubble_Step)); make_pixmap_from_default(st, @@ -1221,6 +1223,7 @@ default_to_pixmaps (struct state *st) default_bubbles[i].size, newpix); /* Now add to list */ + st->def_list[i] = newpix; if (pixmap_list == (Bubble_Step *)NULL) { pixmap_list = newpix; } else { @@ -1278,6 +1281,8 @@ get_resources(struct state *st) else fprintf (stderr, "%s: bogus mode: \"%s\"\n", progname, s); + if (s) free (s); + st->trails = get_boolean_resource(st->dpy, "trails", "Boolean"); st->drop_dir = (st->drop ? 1 : -1); if (st->drop || rise) @@ -1428,9 +1433,38 @@ bubbles_event (Display *dpy, Window window, void *closure, XEvent *event) } static void +free_bubble (Display *dpy, Bubble_Step *b) +{ + if (b->ball) XFreePixmap (dpy, b->ball); + if (b->shape_mask) XFreePixmap (dpy, b->shape_mask); + if (b->draw_gc) XFreeGC (dpy, b->draw_gc); + if (b->erase_gc) XFreeGC (dpy, b->erase_gc); + free (b); +} + +static void bubbles_free (Display *dpy, Window window, void *closure) { struct state *st = (struct state *) closure; + int i; + + /* #### The lifetime of objects in this program is fucking incomprehensible. + I give up. */ + + /* for (i = 0; i < num_default_bubbles; i++) + free_bubble (dpy, st->def_list[i]); */ + for (i = 0; i < st->num_bubble_pixmaps; i++) + free_bubble (dpy, st->step_pixmaps[i]); + for (i = 0; i < st->mesh_cells; i++) + free (st->adjacent_list[i]); + /* for (i = 0; i < st->mesh_cells; i++) + free_bubble (dpy, st->mesh[i]); */ + if (st->draw_gc) XFreeGC (dpy, st->draw_gc); + if (st->erase_gc) XFreeGC (dpy, st->erase_gc); + free (st->adjacent_list); + free (st->def_list); + free (st->step_pixmaps); + free (st->mesh); free (st); } |