Some more memory improvements

* Less leaks
* Less allocations

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
This commit is contained in:
Steffen Jaeckel
2025-03-07 22:31:58 +01:00
parent 9fc0326428
commit 95c2199ca2
10 changed files with 63 additions and 21 deletions

View File

@@ -173,8 +173,6 @@ create_input_window(void)
char*
inp_readline(void)
{
free(inp_line);
inp_line = NULL;
p_rl_timeout.tv_sec = inp_timeout / 1000;
p_rl_timeout.tv_usec = inp_timeout % 1000 * 1000;
FD_ZERO(&fds);
@@ -216,7 +214,9 @@ inp_readline(void)
}
}
}
return strdup(inp_line);
char* ret = inp_line;
inp_line = NULL;
return ret;
} else {
return NULL;
}

View File

@@ -56,6 +56,9 @@
#include "xmpp/muc.h"
static GTimer* remind_timer;
#ifdef HAVE_LIBNOTIFY
static NotifyNotification* notification;
#endif
void
notifier_initialise(void)
@@ -67,6 +70,8 @@ void
notifier_uninit(void)
{
#ifdef HAVE_LIBNOTIFY
g_object_unref(G_OBJECT(notification));
notification = NULL;
if (notify_is_initted()) {
notify_uninit();
}
@@ -208,7 +213,8 @@ notify(const char* const message, int timeout, const char* const category)
notify_init("Profanity");
if (notify_is_initted()) {
NotifyNotification* notification;
if (notification)
g_object_unref(G_OBJECT(notification));
notification = notify_notification_new("Profanity", message, NULL);
notify_notification_set_timeout(notification, timeout);
notify_notification_set_category(notification, category);

View File

@@ -156,12 +156,15 @@ _tray_change_icon(gpointer data)
static void
_tray_shutdown(void)
{
if (gtk_ready && prefs_get_boolean(PREF_TRAY)) {
tray_disable();
tray_disable();
if (icon_filename) {
g_string_free(icon_filename, TRUE);
icon_filename = NULL;
}
if (icon_msg_filename) {
g_string_free(icon_msg_filename, TRUE);
icon_msg_filename = NULL;
}
g_string_free(icon_filename, TRUE);
g_string_free(icon_msg_filename, TRUE);
gtk_main_quit();
}
void
@@ -194,7 +197,9 @@ tray_update(void)
void
tray_set_timer(int interval)
{
g_source_remove(timer);
if (timer) {
g_source_remove(timer);
}
_tray_change_icon(NULL);
timer = g_timeout_add(interval * 1000, _tray_change_icon, NULL);
}
@@ -219,7 +224,10 @@ void
tray_disable(void)
{
shutting_down = TRUE;
g_source_remove(timer);
if (timer) {
g_source_remove(timer);
timer = 0;
}
if (prof_tray) {
g_clear_object(&prof_tray);
prof_tray = NULL;