mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-25 13:55:34 -05:00
Small memory leaks fixed and other cleanups.
This commit is contained in:
parent
4de46aece6
commit
b68f64ccee
8 changed files with 26 additions and 15 deletions
|
@ -243,8 +243,9 @@ static char *combi_mgrv(const Mode *sw, unsigned int selected_line, int *state,
|
||||||
*state |= MARKUP;
|
*state |= MARKUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
retv = helper_string_replace_if_exists(
|
retv = helper_string_replace_if_exists(config.combi_display_format,
|
||||||
config.combi_display_format, "{mode}", dname, "{text}", str, NULL);
|
"{mode}", dname, "{text}", str,
|
||||||
|
(char *)0);
|
||||||
g_free(str);
|
g_free(str);
|
||||||
|
|
||||||
if (attr_list != NULL) {
|
if (attr_list != NULL) {
|
||||||
|
|
|
@ -388,14 +388,14 @@ static gchar *dmenu_format_output_string(const DmenuModePrivateData *pd,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (uint32_t i = 0; pd->columns && pd->columns[i]; i++) {
|
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);
|
(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) {
|
if (i == 0) {
|
||||||
g_string_append(str_retv, splitted[index - 1]);
|
g_string_append(str_retv, splitted[col_index - 1]);
|
||||||
} else {
|
} else {
|
||||||
g_string_append_c(str_retv, '\t');
|
g_string_append_c(str_retv, '\t');
|
||||||
g_string_append(str_retv, splitted[index - 1]);
|
g_string_append(str_retv, splitted[col_index - 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1323,11 +1323,12 @@ static char *_get_display_value(const Mode *sw, unsigned int selected_line,
|
||||||
char *retv = helper_string_replace_if_exists(
|
char *retv = helper_string_replace_if_exists(
|
||||||
config.drun_display_format, "{generic}", egn, "{name}", en, "{comment}",
|
config.drun_display_format, "{generic}", egn, "{name}", en, "{comment}",
|
||||||
ec, "{exec}", dr->exec, "{categories}", cats, "{keywords}", keywords,
|
ec, "{exec}", dr->exec, "{categories}", cats, "{keywords}", keywords,
|
||||||
NULL);
|
(char *)0);
|
||||||
g_free(egn);
|
g_free(egn);
|
||||||
g_free(en);
|
g_free(en);
|
||||||
g_free(ec);
|
g_free(ec);
|
||||||
g_free(cats);
|
g_free(cats);
|
||||||
|
g_free(keywords);
|
||||||
return retv;
|
return retv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -868,7 +868,7 @@ static void window_mode_destroy(Mode *sw) {
|
||||||
}
|
}
|
||||||
struct arg {
|
struct arg {
|
||||||
const WindowModePrivateData *pd;
|
const WindowModePrivateData *pd;
|
||||||
client *c;
|
const client *c;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void helper_eval_add_str(GString *str, const char *input, int l,
|
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;
|
return FALSE;
|
||||||
}
|
}
|
||||||
static char *_generate_display_string(const WindowModePrivateData *pd,
|
static char *_generate_display_string(const WindowModePrivateData *pd,
|
||||||
client *c) {
|
const client *c) {
|
||||||
struct arg d = {pd, c};
|
struct arg d = {pd, c};
|
||||||
char *res = g_regex_replace_eval(pd->window_regex, config.window_format, -1,
|
char *res = g_regex_replace_eval(pd->window_regex, config.window_format, -1,
|
||||||
0, 0, helper_eval_cb, &d, NULL);
|
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 *state, G_GNUC_UNUSED GList **list,
|
||||||
int get_entry) {
|
int get_entry) {
|
||||||
WindowModePrivateData *rmpd = mode_get_private_data(sw);
|
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) {
|
if (c == NULL) {
|
||||||
return get_entry ? g_strdup("Window has vanished") : NULL;
|
return get_entry ? g_strdup("Window has vanished") : NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -350,6 +350,7 @@ static void rofi_icon_fetcher_worker(thread_state *sdata,
|
||||||
const char *suf = strrchr(icon_path, '.');
|
const char *suf = strrchr(icon_path, '.');
|
||||||
if (suf == NULL) {
|
if (suf == NULL) {
|
||||||
sentry->query_done = TRUE;
|
sentry->query_done = TRUE;
|
||||||
|
g_free(icon_path_);
|
||||||
rofi_view_reload();
|
rofi_view_reload();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -485,9 +485,9 @@ static void rofi_view_reload_message_bar(RofiViewState *state) {
|
||||||
GList *iter = g_list_first(list_of_warning_msgs);
|
GList *iter = g_list_first(list_of_warning_msgs);
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (; iter != NULL && index < 2; iter = g_list_next(iter)) {
|
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, "\n\n");
|
||||||
g_string_append(emesg, msg->str);
|
g_string_append(emesg, in_msg->str);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
if (g_list_length(iter) > 1) {
|
if (g_list_length(iter) > 1) {
|
||||||
|
@ -971,6 +971,9 @@ static void input_history_save(void) {
|
||||||
}
|
}
|
||||||
// Cleanups.
|
// Cleanups.
|
||||||
if (CacheState.entry_history != NULL) {
|
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);
|
g_free(CacheState.entry_history);
|
||||||
CacheState.entry_history = NULL;
|
CacheState.entry_history = NULL;
|
||||||
CacheState.entry_history_length = 0;
|
CacheState.entry_history_length = 0;
|
||||||
|
|
|
@ -174,7 +174,7 @@ static void listview_add_widget(listview *lv, _listview_row *row, widget *wid,
|
||||||
} else if (strcasecmp(label, "element-text") == 0) {
|
} else if (strcasecmp(label, "element-text") == 0) {
|
||||||
row->textbox =
|
row->textbox =
|
||||||
textbox_create(WIDGET(wid), WIDGET_TYPE_TEXTBOX_TEXT, "element-text",
|
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);
|
textbox_set_ellipsize(row->textbox, lv->emode);
|
||||||
box_add((box *)wid, WIDGET(row->textbox), TRUE);
|
box_add((box *)wid, WIDGET(row->textbox), TRUE);
|
||||||
} else if (strcasecmp(label, "element-index") == 0) {
|
} else if (strcasecmp(label, "element-index") == 0) {
|
||||||
|
@ -617,7 +617,7 @@ void listview_set_selected(listview *lv, unsigned int selected) {
|
||||||
if (lv->sc_callback) {
|
if (lv->sc_callback) {
|
||||||
lv->sc_callback(lv, lv->selected, lv->sc_udata);
|
lv->sc_callback(lv, lv->selected, lv->sc_udata);
|
||||||
}
|
}
|
||||||
} else if (lv->req_elements == 0) {
|
} else {
|
||||||
if (lv->sc_callback) {
|
if (lv->sc_callback) {
|
||||||
lv->sc_callback(lv, UINT32_MAX, lv->sc_udata);
|
lv->sc_callback(lv, UINT32_MAX, lv->sc_udata);
|
||||||
}
|
}
|
||||||
|
|
|
@ -365,7 +365,12 @@ char *textbox_get_text(const textbox *tb) {
|
||||||
}
|
}
|
||||||
return g_strdup(tb->text);
|
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
|
// set the default text to display
|
||||||
void textbox_text(textbox *tb, const char *text) {
|
void textbox_text(textbox *tb, const char *text) {
|
||||||
if (tb == NULL) {
|
if (tb == NULL) {
|
||||||
|
|
Loading…
Reference in a new issue