From 62c3e8165514d1fb0683ae36e4e5d60f2d9755ba Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Wed, 5 Mar 2008 02:15:43 -0500 Subject: [PATCH] fix some memory problems --- Makefile | 4 ++-- dcompmgr.c | 14 +++++++------- display.c | 6 ++++-- display.h | 1 - efence.h | 5 +++++ list.c | 2 ++ plugin.c | 2 ++ render.c | 2 ++ screen.c | 11 ++++++++--- window.c | 4 ++++ 10 files changed, 36 insertions(+), 15 deletions(-) create mode 100644 efence.h diff --git a/Makefile b/Makefile index 3bdb1ba..d3d8202 100644 --- a/Makefile +++ b/Makefile @@ -2,8 +2,8 @@ sources = $(wildcard *.c) objs = $(sources:.c=.o) headers = $(wildcard *.h) -CFLAGS=$(shell pkg-config --cflags xcb-composite xcb-damage glib-2.0) -ggdb -W -Wall -LIBS=$(shell pkg-config --libs xcb-composite xcb-damage glib-2.0) # -lefence +CFLAGS=$(shell pkg-config --cflags xcb-composite xcb-damage glib-2.0) -ggdb -W -Wall #-DEFENCE +LIBS=$(shell pkg-config --libs xcb-composite xcb-damage glib-2.0) #-lefence dcompmgr: $(objs) $(CC) -o $@ $^ $(LIBS) $(LDFLAGS) diff --git a/dcompmgr.c b/dcompmgr.c index 7067a11..29ec004 100644 --- a/dcompmgr.c +++ b/dcompmgr.c @@ -1,3 +1,5 @@ +#include "efence.h" + #include "screen.h" #include "window.h" #include "list.h" @@ -59,7 +61,6 @@ event(d_display_t *dpy) sc = display_screen_from_root(dpy, cev->parent); if (!sc) break; w = screen_add_window(sc, cev->window); - printf("created 0x%x\n", w); break; } case XCB_DESTROY_NOTIFY: @@ -73,7 +74,6 @@ event(d_display_t *dpy) sc = display_screen_from_root(dpy, dev->event); if (!sc) break; w = screen_find_window(sc, dev->window); - printf("destroyed 0x%x\n", w); vis = window_is_mapped(w); sc->window_hide(w); screen_remove_window(sc, w); @@ -95,7 +95,6 @@ event(d_display_t *dpy) else { sc->window_hide(w); screen_remove_window(sc, w); - printf("reparent lost 0x%x\n", w); } screen_refresh(w->sc); break; @@ -110,7 +109,6 @@ event(d_display_t *dpy) sc = display_screen_from_root(dpy, mev->event); if (!sc) break; w = screen_find_window(sc, mev->window); - printf("mapping 0x%x\n", w); sc->window_show(w); screen_refresh(w->sc); break; @@ -345,7 +343,7 @@ main(int argc, char **argv) for (sc_it = list_top(dpy->screens); sc_it; sc_it = sc_it->next) { d_screen_t *sc = sc_it->data; d_list_it_t *it; - for (it = list_top(sc->stacking); it; it = it->next) + for (it = list_bottom(sc->stacking); it; it = it->prev) if (window_is_mapped(it->data)) sc->window_show(it->data); } @@ -360,8 +358,10 @@ main(int argc, char **argv) for (sc_it = list_top(dpy->screens); sc_it; sc_it = sc_it->next) { d_screen_t *sc = sc_it->data; d_list_it_t *it; - for (it = list_top(sc->stacking); it; it = it->next) - sc->window_hide(it->data); + for (it = list_top(sc->stacking); it; it = it->next) { + if (window_is_mapped(it->data)) + sc->window_hide(it->data); + } } } diff --git a/display.c b/display.c index 1beee21..1ce9e13 100644 --- a/display.c +++ b/display.c @@ -1,3 +1,5 @@ +#include "efence.h" + #include "display.h" #include "screen.h" #include "list.h" @@ -195,11 +197,11 @@ display_unref(d_display_t *dpy) if (dpy && --dpy->ref == 0) { d_list_it_t *it; - xcb_disconnect(dpy->conn); - for (it = list_top(dpy->screens); it; it = it->next) screen_unref(it->data); list_unref(dpy->screens); + + xcb_disconnect(dpy->conn); free(dpy); } } diff --git a/display.h b/display.h index a1844e7..00bb8b1 100644 --- a/display.h +++ b/display.h @@ -2,7 +2,6 @@ #define dc__display_h #include -//#include #include diff --git a/efence.h b/efence.h new file mode 100644 index 0000000..d1c4f97 --- /dev/null +++ b/efence.h @@ -0,0 +1,5 @@ +#ifdef EFENCE +#include +#include +#include +#endif diff --git a/list.c b/list.c index 49a9f78..2339b06 100644 --- a/list.c +++ b/list.c @@ -1,3 +1,5 @@ +#include "efence.h" + #include "list.h" #include #include diff --git a/plugin.c b/plugin.c index bb838ad..4d32126 100644 --- a/plugin.c +++ b/plugin.c @@ -1,3 +1,5 @@ +#include "efence.h" + #include "plugin.h" #include "list.h" #include diff --git a/render.c b/render.c index 5510a5c..8d272fb 100644 --- a/render.c +++ b/render.c @@ -1,3 +1,5 @@ +#include "efence.h" + #include "render.h" #include "screen.h" #include "window.h" diff --git a/screen.c b/screen.c index 91195af..b16373a 100644 --- a/screen.c +++ b/screen.c @@ -1,3 +1,5 @@ +#include "efence.h" + #include "screen.h" #include "display.h" #include "plugin.h" @@ -61,11 +63,13 @@ void screen_unref(d_screen_t *sc) { if (sc && --sc->ref == 0) { - d_list_it_t *it; + d_list_it_t *it, *next; g_hash_table_unref(sc->winhash); - for (it = list_top(sc->stacking); it; it = it->next) + for (it = list_top(sc->stacking); it; it = next) { + next = it->next; window_unref(it->data); + } list_unref(sc->stacking); list_unref(sc->plugin_data); free(sc); @@ -350,7 +354,8 @@ screen_remove_plugin_data(d_screen_t *sc, int id) plugin_data_remove(sc->plugin_data, id); } -void screen_refresh(d_screen_t *sc) +void +screen_refresh(d_screen_t *sc) { sc->need_repaint = TRUE; //printf("*** need repaint! ***\n"); diff --git a/window.c b/window.c index 379bafc..f4a97a9 100644 --- a/window.c +++ b/window.c @@ -1,3 +1,5 @@ +#include "efence.h" + #include "window.h" #include "screen.h" #include "plugin.h" @@ -342,6 +344,7 @@ window_create_damage(d_window_t *pubw) if (!window_is_input_only(pubw)) { assert(w->damage == XCB_NONE); w->damage = xcb_generate_id(w->sc->dpy->conn); + //printf("creating damage 0x%x\n", w->damage); xcb_damage_create(w->sc->dpy->conn, w->damage, w->id, XCB_DAMAGE_REPORT_LEVEL_NON_EMPTY); } @@ -352,6 +355,7 @@ void window_destroy_damage(d_window_t *pubw) d_window_priv_t *w = (d_window_priv_t*)pubw; if (w->damage) { + //printf("destroying damage 0x%x\n", w->damage); xcb_damage_destroy(w->sc->dpy->conn, w->damage); w->damage = XCB_NONE; } -- 1.9.1