diff options
author | Thomas Thurman <tthurman@gnome.org> | 2009-10-28 12:29:47 -0400 |
---|---|---|
committer | Thomas Thurman <tthurman@gnome.org> | 2009-10-28 12:29:47 -0400 |
commit | 81beaef007317ee977f3e9d856b5955196a1275b (patch) | |
tree | 9a2f2b706316f82e579af0d6ade91467a4ea2d61 | |
parent | f53914b0959a179f504b9197dd89efe8386f5b55 (diff) | |
download | metacity-81beaef007317ee977f3e9d856b5955196a1275b.tar.gz |
plug memory leak
-rw-r--r-- | src/ui/theme.c | 50 | ||||
-rw-r--r-- | src/ui/theme.h | 58 |
2 files changed, 57 insertions, 51 deletions
diff --git a/src/ui/theme.c b/src/ui/theme.c index ee075116..79d2830c 100644 --- a/src/ui/theme.c +++ b/src/ui/theme.c @@ -8,37 +8,6 @@ #include <ccss-cairo/ccss-cairo.h> #include <gtk/gtk.h> -/** - * Coordinates and sizes of part of the window. - * Only used within this file. - */ -struct _CowbellArea { - /** - * Sizes of padding (except for the frame) plus - * borders plus margins. - */ - int top_edge; - int left_edge; - int bottom_edge; - int right_edge; - - /** - * Sizes of *just* the margins. - */ - int top_margin; - int left_margin; - int bottom_margin; - int right_margin; - - /** - * The position of the area. - */ - int x; - int y; - int width; - int height; -}; - struct _MetaTheme { ccss_grammar_t *grammar; ccss_stylesheet_t *stylesheet; @@ -52,21 +21,6 @@ MetaTheme *the_theme = NULL; /****************************************************************/ -/* Our little hierarchy */ -typedef enum _CopperClasses { - CC_FRAME, - CC_CONTENT, CC_TITLEBAR, - CC_TITLE, - CC_MENU, - CC_BUTTON_FIRST = CC_MENU, - CC_MINIMIZE, CC_MAXIMIZE, CC_CLOSE, - CC_SHADE, CC_ABOVE, CC_STICK, - CC_UNSHADE, CC_UNABOVE, CC_UNSTICK, - CC_BUTTON_LAST = CC_UNSTICK, - CC_FILLER, - CC_LAST -} CopperClasses; - /** * The element names of each CopperClass. * @@ -900,9 +854,7 @@ meta_theme_calc_geometry (MetaTheme *theme, /* TODO - We may want to cache the style objects in "areas" */ - /* FIXME FIXME FIXME */ - /* This will LEAK. We must provide a constructor and destructor fn. */ - fgeom->areas = g_new0 (CowbellArea, CC_LAST); + memset (&(fgeom->areas), 0, sizeof(fgeom->areas)); /* First of all, we need to calculate the edges for each element. */ for (i=0; i<CC_LAST; i++) diff --git a/src/ui/theme.h b/src/ui/theme.h index a881e52e..f896d79b 100644 --- a/src/ui/theme.h +++ b/src/ui/theme.h @@ -81,7 +81,61 @@ typedef struct GdkRectangle clickable; } MetaButtonSpace; -typedef struct _CowbellArea CowbellArea; +/** + * The elements which can be styled using CSS. + * + * (I didn't want to make these publicly visible, + * but the alternative would have been to make "areas" + * in MetaFrameGeometry a pointer, which would have + * required us to add destructors everywhere it was + * used.) + */ +typedef enum _CopperClasses { + CC_FRAME, + CC_CONTENT, CC_TITLEBAR, + CC_TITLE, + CC_MENU, + CC_BUTTON_FIRST = CC_MENU, + CC_MINIMIZE, CC_MAXIMIZE, CC_CLOSE, + CC_SHADE, CC_ABOVE, CC_STICK, + CC_UNSHADE, CC_UNABOVE, CC_UNSTICK, + CC_BUTTON_LAST = CC_UNSTICK, + CC_FILLER, + CC_LAST +} CopperClasses; + +/** + * Coordinates and sizes of part of the window. + * Only used within theme.c. + * See comment on CopperClasses for what this + * is doing here. + */ +typedef struct _CowbellArea { + /** + * Sizes of padding (except for the frame) plus + * borders plus margins. + */ + int top_edge; + int left_edge; + int bottom_edge; + int right_edge; + + /** + * Sizes of *just* the margins. + */ + int top_margin; + int left_margin; + int bottom_margin; + int right_margin; + + /** + * The position of the area. + */ + int x; + int y; + int width; + int height; +} CowbellArea; /** * Calculated actual geometry of the frame @@ -103,7 +157,7 @@ typedef struct int top_titlebar_edge; int bottom_titlebar_edge; - CowbellArea *areas; + CowbellArea areas[CC_LAST]; /* used for a memset hack */ #define ADDRESS_OF_BUTTON_RECTS(fgeom) (((char*)(fgeom)) + G_STRUCT_OFFSET (MetaFrameGeometry, close_rect)) |