diff options
author | Dave Davenport <qball@gmpclient.org> | 2016-10-18 13:49:24 +0200 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2016-10-18 13:49:24 +0200 |
commit | 7b3b68462e039d540ad029d94c3b8fb876887472 (patch) | |
tree | b0e15e39e0c38e2bd240a79c01ad7d9459223fdf /source | |
parent | 2c0c3c675aae8283d79a61d151fa0aaa9d438182 (diff) |
Fix memory leak in box and listview widget, add coverage make target. (ggcov and lcov)
Diffstat (limited to 'source')
-rw-r--r-- | source/dialogs/drun.c | 2 | ||||
-rw-r--r-- | source/dialogs/ssh.c | 2 | ||||
-rw-r--r-- | source/helper.c | 4 | ||||
-rw-r--r-- | source/rofi.c | 2 | ||||
-rw-r--r-- | source/widgets/box.c | 6 | ||||
-rw-r--r-- | source/widgets/listview.c | 12 | ||||
-rw-r--r-- | source/widgets/widget.c | 6 | ||||
-rw-r--r-- | source/xrmoptions.c | 2 |
8 files changed, 22 insertions, 14 deletions
diff --git a/source/dialogs/drun.c b/source/dialogs/drun.c index e9dd16cd..da0c3c26 100644 --- a/source/dialogs/drun.c +++ b/source/dialogs/drun.c @@ -366,7 +366,7 @@ static void walk_dir ( DRunModePrivateData *pd, const char *root, const char *di } // Skip files not ending on .desktop. if ( file->d_type != DT_DIR && !g_str_has_suffix ( file->d_name, ".desktop" ) ) { - g_free(filename); + g_free ( filename ); continue; } diff --git a/source/dialogs/ssh.c b/source/dialogs/ssh.c index f11ba3a1..397893dc 100644 --- a/source/dialogs/ssh.c +++ b/source/dialogs/ssh.c @@ -198,7 +198,7 @@ static char **read_hosts_file ( char ** retv, unsigned int *length ) // Reading one line per time. while ( getline ( &buffer, &buffer_length, fd ) > 0 ) { // Evaluate one line. - unsigned int index = 0, ti = 0; + unsigned int index = 0, ti = 0; char *token = buffer; // Tokenize it. diff --git a/source/helper.c b/source/helper.c index 773c8fc3..7fabbcea 100644 --- a/source/helper.c +++ b/source/helper.c @@ -194,7 +194,7 @@ static GRegex * create_regex ( const char *input, int case_sensitive ) { #define R( s ) g_regex_new ( s, G_REGEX_OPTIMIZE | ( ( case_sensitive ) ? 0 : G_REGEX_CASELESS ), 0, NULL ) GRegex * retv = NULL; - gchar *r; + gchar *r; switch ( config.matching_method ) { case MM_GLOB: @@ -234,7 +234,7 @@ GRegex **tokenize ( const char *input, int case_sensitive ) } char *saveptr = NULL, *token; - GRegex **retv = NULL; + GRegex **retv = NULL; if ( !config.tokenize ) { retv = g_malloc0 ( sizeof ( GRegex* ) * 2 ); retv[0] = (GRegex *) create_regex ( input, case_sensitive ); diff --git a/source/rofi.c b/source/rofi.c index 46b81ae7..391d8f21 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -344,7 +344,7 @@ static int add_mode ( const char * token ) } else #endif // WINDOW_MODE - // SSh dialog + // SSh dialog if ( strcasecmp ( token, "ssh" ) == 0 ) { modi[num_modi] = &ssh_mode; num_modi++; diff --git a/source/widgets/box.c b/source/widgets/box.c index 6f5b12de..bb36f292 100644 --- a/source/widgets/box.c +++ b/source/widgets/box.c @@ -202,13 +202,15 @@ static void box_free ( widget *wid ) widget * child = (widget *) iter->data; widget_free ( child ); } - + g_list_free ( b->children ); g_free ( b ); } void box_add ( box *box, widget *child, gboolean expand, gboolean end ) { - if ( box == NULL ) return; + if ( box == NULL ) { + return; + } child->expand = expand; child->end = end; child->parent = WIDGET ( box ); diff --git a/source/widgets/listview.c b/source/widgets/listview.c index 055be2f6..ce6072e0 100644 --- a/source/widgets/listview.c +++ b/source/widgets/listview.c @@ -71,9 +71,15 @@ struct _listview void *mouse_activated_data; }; -static void listview_free ( widget *widget ) +static void listview_free ( widget *wid ) { - listview *lv = (listview *) widget; + listview *lv = (listview *) wid; + for ( unsigned int i = 0; i < lv->cur_elements; i++ ) { + widget_free ( WIDGET ( lv->boxes [i] ) ); + } + g_free ( lv->boxes ); + + widget_free ( WIDGET ( lv->scrollbar ) ); g_free ( lv ); } static unsigned int scroll_per_page ( listview * lv ) @@ -237,7 +243,7 @@ static void listview_resize ( widget *wid, short w, short h ) lv->max_rows = ( lv->padding + lv->widget.h ) / ( lv->element_height + lv->padding ); lv->max_elements = lv->max_rows * lv->menu_columns; - widget_move ( WIDGET ( lv->scrollbar ), lv->widget.w - widget_get_width ( WIDGET (lv->scrollbar ) ), 0 ); + widget_move ( WIDGET ( lv->scrollbar ), lv->widget.w - widget_get_width ( WIDGET ( lv->scrollbar ) ), 0 ); widget_resize ( WIDGET ( lv->scrollbar ), widget_get_width ( WIDGET ( lv->scrollbar ) ), h ); listview_recompute_elements ( lv ); diff --git a/source/widgets/widget.c b/source/widgets/widget.c index 48642cb7..0aee2e70 100644 --- a/source/widgets/widget.c +++ b/source/widgets/widget.c @@ -66,10 +66,10 @@ void widget_draw ( widget *widget, cairo_t *d ) widget->need_redraw = FALSE; } } -void widget_free ( widget *widget ) +void widget_free ( widget *wid ) { - if ( widget && widget->free ) { - widget->free ( widget ); + if ( wid && wid->free ) { + wid->free ( wid ); } } diff --git a/source/xrmoptions.c b/source/xrmoptions.c index 0217833e..6d69e1d9 100644 --- a/source/xrmoptions.c +++ b/source/xrmoptions.c @@ -197,7 +197,7 @@ static XrmOption xrmOptions[] = { }; /** Dynamic array of extra options */ -XrmOption *extra_options = NULL; +XrmOption *extra_options = NULL; /** Number of entries in extra options array */ unsigned int num_extra_options = 0; |