Merge pull request #418 from bebehei/microopt

Microopt
This commit is contained in:
Nikos Tsipinakis 2017-10-24 06:03:58 +03:00 committed by GitHub
commit a2575566f5
8 changed files with 76 additions and 90 deletions

View File

@ -20,8 +20,6 @@
#include "x11/x.h" #include "x11/x.h"
#include "x11/screen.h" #include "x11/screen.h"
#define LENGTH(X) (sizeof X / sizeof X[0])
#ifndef VERSION #ifndef VERSION
#define VERSION "version info needed" #define VERSION "version info needed"
#endif #endif
@ -318,7 +316,7 @@ int dunst_main(int argc, char *argv[])
n->summary = g_strdup("startup"); n->summary = g_strdup("startup");
n->body = g_strdup("dunst is up and running"); n->body = g_strdup("dunst is up and running");
n->progress = 0; n->progress = 0;
n->timeout = 10; n->timeout = 10 * G_USEC_PER_SEC;
n->markup = MARKUP_NO; n->markup = MARKUP_NO;
n->urgency = LOW; n->urgency = LOW;
notification_init(n, 0); notification_init(n, 0);

View File

@ -9,9 +9,7 @@
#include "notification.h" #include "notification.h"
#define ERR(msg) printf("%s : %d\n", (msg), __LINE__)
#define PERR(msg, errnum) printf("(%d) %s : %s\n", __LINE__, (msg), (strerror(errnum))) #define PERR(msg, errnum) printf("(%d) %s : %s\n", __LINE__, (msg), (strerror(errnum)))
#define LENGTH(X) (sizeof X / sizeof X[0])
#define ColLast 3 #define ColLast 3
#define ColFrame 2 #define ColFrame 2

View File

@ -176,11 +176,7 @@ void notification_free(notification *n)
g_free(n->msg); g_free(n->msg);
g_free(n->dbus_client); g_free(n->dbus_client);
g_free(n->category); g_free(n->category);
if (n->text_to_render)
g_free(n->text_to_render); g_free(n->text_to_render);
if (n->urls)
g_free(n->urls); g_free(n->urls);
if (n->actions) { if (n->actions) {
@ -642,10 +638,8 @@ bool notification_replace_by_id(notification *new)
void notification_update_text_to_render(notification *n) void notification_update_text_to_render(notification *n)
{ {
if (n->text_to_render) {
g_free(n->text_to_render); g_free(n->text_to_render);
n->text_to_render = NULL; n->text_to_render = NULL;
}
char *buf = NULL; char *buf = NULL;

View File

@ -248,7 +248,6 @@ int load_ini_file(FILE *fp)
*end = '\0'; *end = '\0';
if (current_section)
g_free(current_section); g_free(current_section);
current_section = (g_strdup(start + 1)); current_section = (g_strdup(start + 1));
new_section(current_section); new_section(current_section);
@ -296,7 +295,6 @@ int load_ini_file(FILE *fp)
add_entry(current_section, key, value); add_entry(current_section, key, value);
} }
free(line); free(line);
if (current_section)
g_free(current_section); g_free(current_section);
return 0; return 0;
} }

View File

@ -23,7 +23,6 @@ void rule_apply(rule_t *r, notification *n)
if (r->markup != MARKUP_NULL) if (r->markup != MARKUP_NULL)
n->markup = r->markup; n->markup = r->markup;
if (r->new_icon) { if (r->new_icon) {
if(n->icon)
g_free(n->icon); g_free(n->icon);
n->icon = g_strdup(r->new_icon); n->icon = g_strdup(r->new_icon);
n->icon_overridden = true; n->icon_overridden = true;

View File

@ -64,7 +64,6 @@ static int ini_get_urgency(const char *section, const char *key, const int def)
"unknown urgency: %s, ignoring\n", "unknown urgency: %s, ignoring\n",
urg); urg);
} }
if (urg)
g_free(urg); g_free(urg);
return ret; return ret;
} }
@ -601,7 +600,7 @@ void load_settings(char *cmdline_config_path)
); );
/* push hardcoded default rules into rules list */ /* push hardcoded default rules into rules list */
for (int i = 0; i < LENGTH(default_rules); i++) { for (int i = 0; i < G_N_ELEMENTS(default_rules); i++) {
rules = g_slist_insert(rules, &(default_rules[i]), -1); rules = g_slist_insert(rules, &(default_rules[i]), -1);
} }