summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2023-04-21 12:50:55 +0200
committerDave Davenport <qball@gmpclient.org>2023-04-21 12:50:55 +0200
commitb68f64ccee0ddcca4b530a30e40079883dced8bc (patch)
tree35b0d0df5c04e37e64f52d04fcaa7d299a9a7c81
parent4de46aece67eb4e01101e1d24fd49d8fd856e84d (diff)
Small memory leaks fixed and other cleanups.
-rw-r--r--source/modes/combi.c5
-rw-r--r--source/modes/dmenu.c8
-rw-r--r--source/modes/drun.c3
-rw-r--r--source/modes/window.c6
-rw-r--r--source/rofi-icon-fetcher.c1
-rw-r--r--source/view.c7
-rw-r--r--source/widgets/listview.c4
-rw-r--r--source/widgets/textbox.c7
8 files changed, 26 insertions, 15 deletions
diff --git a/source/modes/combi.c b/source/modes/combi.c
index 741219bb..3542e72a 100644
--- a/source/modes/combi.c
+++ b/source/modes/combi.c
@@ -243,8 +243,9 @@ static char *combi_mgrv(const Mode *sw, unsigned int selected_line, int *state,
*state |= MARKUP;
}
- retv = helper_string_replace_if_exists(
- config.combi_display_format, "{mode}", dname, "{text}", str, NULL);
+ retv = helper_string_replace_if_exists(config.combi_display_format,
+ "{mode}", dname, "{text}", str,
+ (char *)0);
g_free(str);
if (attr_list != NULL) {
diff --git a/source/modes/dmenu.c b/source/modes/dmenu.c
index 27b6097d..b005cfb0 100644
--- a/source/modes/dmenu.c
+++ b/source/modes/dmenu.c
@@ -388,14 +388,14 @@ static gchar *dmenu_format_output_string(const DmenuModePrivateData *pd,
}
}
for (uint32_t i = 0; pd->columns && pd->columns[i]; i++) {
- unsigned int index =
+ unsigned int col_index =
(unsigned int)g_ascii_strtoull(pd->columns[i], NULL, 10);
- if (index <= ns && index > 0) {
+ if (col_index <= ns && col_index > 0) {
if (i == 0) {
- g_string_append(str_retv, splitted[index - 1]);
+ g_string_append(str_retv, splitted[col_index - 1]);
} else {
g_string_append_c(str_retv, '\t');
- g_string_append(str_retv, splitted[index - 1]);
+ g_string_append(str_retv, splitted[col_index - 1]);
}
}
}
diff --git a/source/modes/drun.c b/source/modes/drun.c
index 3e82561b..dced6db7 100644
--- a/source/modes/drun.c
+++ b/source/modes/drun.c
@@ -1323,11 +1323,12 @@ static char *_get_display_value(const Mode *sw, unsigned int selected_line,
char *retv = helper_string_replace_if_exists(
config.drun_display_format, "{generic}", egn, "{name}", en, "{comment}",
ec, "{exec}", dr->exec, "{categories}", cats, "{keywords}", keywords,
- NULL);
+ (char *)0);
g_free(egn);
g_free(en);
g_free(ec);
g_free(cats);
+ g_free(keywords);
return retv;
}
diff --git a/source/modes/window.c b/source/modes/window.c
index 1d48759a..5ac4a8f8 100644
--- a/source/modes/window.c
+++ b/source/modes/window.c
@@ -868,7 +868,7 @@ static void window_mode_destroy(Mode *sw) {
}
struct arg {
const WindowModePrivateData *pd;
- client *c;
+ const client *c;
};
static void helper_eval_add_str(GString *str, const char *input, int l,
@@ -932,7 +932,7 @@ static gboolean helper_eval_cb(const GMatchInfo *info, GString *str,
return FALSE;
}
static char *_generate_display_string(const WindowModePrivateData *pd,
- client *c) {
+ const client *c) {
struct arg d = {pd, c};
char *res = g_regex_replace_eval(pd->window_regex, config.window_format, -1,
0, 0, helper_eval_cb, &d, NULL);
@@ -943,7 +943,7 @@ static char *_get_display_value(const Mode *sw, unsigned int selected_line,
int *state, G_GNUC_UNUSED GList **list,
int get_entry) {
WindowModePrivateData *rmpd = mode_get_private_data(sw);
- client *c = window_client(rmpd, rmpd->ids->array[selected_line]);
+ const client *c = window_client(rmpd, rmpd->ids->array[selected_line]);
if (c == NULL) {
return get_entry ? g_strdup("Window has vanished") : NULL;
}
diff --git a/source/rofi-icon-fetcher.c b/source/rofi-icon-fetcher.c
index 563e3d12..f4f9086d 100644
--- a/source/rofi-icon-fetcher.c
+++ b/source/rofi-icon-fetcher.c
@@ -350,6 +350,7 @@ static void rofi_icon_fetcher_worker(thread_state *sdata,
const char *suf = strrchr(icon_path, '.');
if (suf == NULL) {
sentry->query_done = TRUE;
+ g_free(icon_path_);
rofi_view_reload();
return;
}
diff --git a/source/view.c b/source/view.c
index 16ecb088..e685f101 100644
--- a/source/view.c
+++ b/source/view.c
@@ -485,9 +485,9 @@ static void rofi_view_reload_message_bar(RofiViewState *state) {
GList *iter = g_list_first(list_of_warning_msgs);
int index = 0;
for (; iter != NULL && index < 2; iter = g_list_next(iter)) {
- GString *msg = (GString *)(iter->data);
+ GString *in_msg = (GString *)(iter->data);
g_string_append(emesg, "\n\n");
- g_string_append(emesg, msg->str);
+ g_string_append(emesg, in_msg->str);
index++;
}
if (g_list_length(iter) > 1) {
@@ -971,6 +971,9 @@ static void input_history_save(void) {
}
// Cleanups.
if (CacheState.entry_history != NULL) {
+ for (ssize_t i = 0; i < CacheState.entry_history_length; i++) {
+ g_free(CacheState.entry_history[i].string);
+ }
g_free(CacheState.entry_history);
CacheState.entry_history = NULL;
CacheState.entry_history_length = 0;
diff --git a/source/widgets/listview.c b/source/widgets/listview.c
index 09a8e542..2e333cb6 100644
--- a/source/widgets/listview.c
+++ b/source/widgets/listview.c
@@ -174,7 +174,7 @@ static void listview_add_widget(listview *lv, _listview_row *row, widget *wid,
} else if (strcasecmp(label, "element-text") == 0) {
row->textbox =
textbox_create(WIDGET(wid), WIDGET_TYPE_TEXTBOX_TEXT, "element-text",
- TB_AUTOHEIGHT , NORMAL, "DDD", 0, 0);
+ TB_AUTOHEIGHT, NORMAL, "DDD", 0, 0);
textbox_set_ellipsize(row->textbox, lv->emode);
box_add((box *)wid, WIDGET(row->textbox), TRUE);
} else if (strcasecmp(label, "element-index") == 0) {
@@ -617,7 +617,7 @@ void listview_set_selected(listview *lv, unsigned int selected) {
if (lv->sc_callback) {
lv->sc_callback(lv, lv->selected, lv->sc_udata);
}
- } else if (lv->req_elements == 0) {
+ } else {
if (lv->sc_callback) {
lv->sc_callback(lv, UINT32_MAX, lv->sc_udata);
}
diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c
index 28f91489..6785826a 100644
--- a/source/widgets/textbox.c
+++ b/source/widgets/textbox.c
@@ -365,7 +365,12 @@ char *textbox_get_text(const textbox *tb) {
}
return g_strdup(tb->text);
}
-int textbox_get_cursor(const textbox *tb) { return tb->cursor; }
+int textbox_get_cursor(const textbox *tb) {
+ if (tb) {
+ return tb->cursor;
+ }
+ return 0;
+}
// set the default text to display
void textbox_text(textbox *tb, const char *text) {
if (tb == NULL) {