mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-19 12:16:22 +00:00
Some more memory improvements
* Less leaks * Less allocations Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user